PDA

View Full Version : Where SQL Helo Please.


hughesmi
05-21-2006, 10:53 PM
strSQL = "SELECT * " _
& "FROM tblNews " _
& "WHERE Short_news LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR News_Item LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "WHERE PersonID =" & Session("PersonID")



Could someone please help with the logic of this? I know I can not have two WHERE clauses. I just need the statment to only show the searches from the two tables where the "allowed" user can ONLY see there results. Hence the "WHERE PersonID =" & Session("PersonID").

Roelf
05-22-2006, 08:02 AM
Use () and the keyword AND:

strSQL = "SELECT * " _
& "FROM tblNews " _
& "WHERE (Short_news LIKE '%" & Replace(strSearch, "'", "''") & "%' " _
& "OR News_Item LIKE '%" & Replace(strSearch, "'", "''") & "%' )" _
& "AND PersonID =" & Session("PersonID")

hughesmi
05-22-2006, 05:59 PM
Thanks. It's workig fine now. :thumbsup: