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
databasehelp
6 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.
  • T Offline
    T Offline
    Trustapple
    wrote on last edited by
    #1

    hi, i have a very simple problem....i have a ms access database. I have a windows form, which has two textboxes(name and depid) and a combobox(department),i want to write a query that will search all these using WHERE and LIKE.ie i need to create a function by the name search and use the query so that this will search all these...i am new to sql...expecting your help Thanks in advance, JAN

    B 1 Reply Last reply
    0
    • T Trustapple

      hi, i have a very simple problem....i have a ms access database. I have a windows form, which has two textboxes(name and depid) and a combobox(department),i want to write a query that will search all these using WHERE and LIKE.ie i need to create a function by the name search and use the query so that this will search all these...i am new to sql...expecting your help Thanks in advance, JAN

      B Offline
      B Offline
      Blue_Boy
      wrote on last edited by
      #2

      select * from where name ='deptname' and depid='1' -- instead value 1 on depid set another id for more help describe your problem much more.


      I Love SQL

      T 1 Reply Last reply
      0
      • B Blue_Boy

        select * from where name ='deptname' and depid='1' -- instead value 1 on depid set another id for more help describe your problem much more.


        I Love SQL

        T Offline
        T Offline
        Trustapple
        wrote on last edited by
        #3

        hi, i have three layers. 1)form.cs 2)datalayer 3)database(forget about this since it is used to open and close the connections form the ms access) i have two text and a single combobox. basic idea is i want a query that will search even if any one of these fields are selected. also do the same if two are selected. also do the same if one is selected. the code to search will have to be on my btn click for serach event(ie is in layer form1.cs). it will have to call my query that will be in a fn: that is in datalayer ( public DataTable refinesearch(string searchstr1, string s2, string s3) so i think i need to use "like" condition. something like "select * from Employee(name of the table) where name like "string" where empid like "s2" etc........ this is my problem .i do not know the query. thanking you and expecting your reply.... J

        B 1 Reply Last reply
        0
        • T Trustapple

          hi, i have three layers. 1)form.cs 2)datalayer 3)database(forget about this since it is used to open and close the connections form the ms access) i have two text and a single combobox. basic idea is i want a query that will search even if any one of these fields are selected. also do the same if two are selected. also do the same if one is selected. the code to search will have to be on my btn click for serach event(ie is in layer form1.cs). it will have to call my query that will be in a fn: that is in datalayer ( public DataTable refinesearch(string searchstr1, string s2, string s3) so i think i need to use "like" condition. something like "select * from Employee(name of the table) where name like "string" where empid like "s2" etc........ this is my problem .i do not know the query. thanking you and expecting your reply.... J

          B Offline
          B Offline
          Blue_Boy
          wrote on last edited by
          #4

          if datatype of column EmpId is integer then you can not use like statement just >,<,=,<> but if column EmpId is varchar then you can use like statement --if empid is integer select * from Employee where name like '%string%' and empid=1 --if empid is varchar select * from Employee where name like '%string%' and empid like '%1%' -- modified at 11:38 Saturday 13th October, 2007


          I Love SQL

          T 1 Reply Last reply
          0
          • B Blue_Boy

            if datatype of column EmpId is integer then you can not use like statement just >,<,=,<> but if column EmpId is varchar then you can use like statement --if empid is integer select * from Employee where name like '%string%' and empid=1 --if empid is varchar select * from Employee where name like '%string%' and empid like '%1%' -- modified at 11:38 Saturday 13th October, 2007


            I Love SQL

            T Offline
            T Offline
            Trustapple
            wrote on last edited by
            #5

            Hi, Thankyou Blue_Boy .it worked fine. Thanks a lot for your time.... Regards Jan

            B 1 Reply Last reply
            0
            • T Trustapple

              Hi, Thankyou Blue_Boy .it worked fine. Thanks a lot for your time.... Regards Jan

              B Offline
              B Offline
              Blue_Boy
              wrote on last edited by
              #6

              You are welcomed.


              I Love SQL

              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