Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Query

SQL Query

Scheduled Pinned Locked Moved Database
databasetutorialquestion
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sandhya14
    wrote on last edited by
    #1

    Hi all I have table like Table1 ID Status Flaged 1 NotApproved 1 2 NotApproved 0 3 NotApproved NUll 4 NotApproved NULL here i need to get the ID in which status=NotApproved and Flaged <>1 so the result should be like this 2 NotApproved 0 3 NotApproved NUll 4 NotApproved NULL i should get these 3 records.... hw will write the query?...how to pass the parameters? thanks

    U 1 Reply Last reply
    0
    • S sandhya14

      Hi all I have table like Table1 ID Status Flaged 1 NotApproved 1 2 NotApproved 0 3 NotApproved NUll 4 NotApproved NULL here i need to get the ID in which status=NotApproved and Flaged <>1 so the result should be like this 2 NotApproved 0 3 NotApproved NUll 4 NotApproved NULL i should get these 3 records.... hw will write the query?...how to pass the parameters? thanks

      U Offline
      U Offline
      Ujjaval Modi
      wrote on last edited by
      #2

      Hi, You can write query as follows : select * from Table1 where status='NotApproved' and Flaged NOT LIKE ('1') assuming that both status and flaged field are of varchar data-type.

      Regards, Ujjaval Modi :) Manpower moves wrenches, horsepower moves cars, and the power of the mind moves the world.

      S 1 Reply Last reply
      0
      • U Ujjaval Modi

        Hi, You can write query as follows : select * from Table1 where status='NotApproved' and Flaged NOT LIKE ('1') assuming that both status and flaged field are of varchar data-type.

        Regards, Ujjaval Modi :) Manpower moves wrenches, horsepower moves cars, and the power of the mind moves the world.

        S Offline
        S Offline
        sandhya14
        wrote on last edited by
        #3

        Hi... Thanku soo much for ur reply... :)

        S 1 Reply Last reply
        0
        • S sandhya14

          Hi... Thanku soo much for ur reply... :)

          S Offline
          S Offline
          sandhya14
          wrote on last edited by
          #4

          Hi, that is working when am calling directly in the code....but here i need ta call that as storedprocedure....so i have created that as stored procedure to fill a dropdown... my doubt is how to pass this 'flaged' as parameter...(second parameter) here is my code:- Sub FillRID() Try Initialize("StoredProcedure", "SelectRequestID1new") _cmd.Parameters.Add(New SqlParameter("@ApprovedStatus", "NotApproved")) _cmd.Parameters.Add(New SqlParameter("@Flaged", "")) _dr = _cmd.ExecuteReader() DropDownRID.DataSource = _dr DropDownRID.DataTextField = "ID" DropDownRID.DataValueField = "ID" DropDownRID.DataBind() DropDownRID.Items.Insert(0, "Select RequestID") DropDownRID.SelectedIndex = 0 Catch ex As Exception End Try End Sub

          S 1 Reply Last reply
          0
          • S sandhya14

            Hi, that is working when am calling directly in the code....but here i need ta call that as storedprocedure....so i have created that as stored procedure to fill a dropdown... my doubt is how to pass this 'flaged' as parameter...(second parameter) here is my code:- Sub FillRID() Try Initialize("StoredProcedure", "SelectRequestID1new") _cmd.Parameters.Add(New SqlParameter("@ApprovedStatus", "NotApproved")) _cmd.Parameters.Add(New SqlParameter("@Flaged", "")) _dr = _cmd.ExecuteReader() DropDownRID.DataSource = _dr DropDownRID.DataTextField = "ID" DropDownRID.DataValueField = "ID" DropDownRID.DataBind() DropDownRID.Items.Insert(0, "Select RequestID") DropDownRID.SelectedIndex = 0 Catch ex As Exception End Try End Sub

            S Offline
            S Offline
            sandhya14
            wrote on last edited by
            #5

            sorry i have got the solution....thanks....

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups