Like operator

  • hi i am new in sql

    i am adding simple search in my site for that i wrote a query :

    Select * from posted_job where job_location='" + jb_location + "' and Dept='" + function_area + "' OR Skills like '%''" + skill + "''%' AND status='Y'

    here i want to select those rows where status should be Y, But gives me all rows data even if status is 'N'. please give me solution that

    Thanks in advance

  • You need to separate your OR from your ANDS with parentheses.

    Select * from posted_job where (job_location='" + jb_location + "' and Dept='" + function_area + "' OR Skills like '%''" + skill + "''%') AND status='Y'

    Try that, see if it does what you need.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply