28. maj 2001 - 09:36Der er
10 kommentarer og 1 løsning
search results from 2 tables
I have a search script that I would like to search thru 2 tables and not just the one as it does not what is the best way to do this. As my script stands know it looks like this strSQL = \"SELECT * FROM listall WHERE\" strSQL = strSQL & \" ( name LIKE \'%\" & strKeyword & \"%\')\" strSQL = strSQL & \" OR (descript LIKE \'%\" & strKeyword & \"%\')\" strSQL = strSQL & \" OR (info LIKE \'%\" & strKeyword & \"%\')\" strSQL = strSQL & \" OR (example LIKE \'%\" & strKeyword & \"%\')\"
I changed strSQL = \"SELECT * FROM listall WHERE\" to strSQL = \"SELECT * FROM listall, articals WHERE\" articals is the other table, this of course doesnt work but am I on the right track ?? And how would one call the other columes from the other table ?? I have seen the question here on Eksperten before but just cant seem to find it Any help would be great //Guzzie
strSQL = \"SELECT * FROM listall, articals WHERE\" strSQL = strSQL & \" ( listall.name LIKE \'%\" & strKeyword & \"%\')\" strSQL = strSQL & \" OR (listall.descript LIKE \'%\" & strKeyword & \"%\')\" strSQL = strSQL & \" OR (listall.info LIKE \'%\" & strKeyword & \"%\')\" strSQL = strSQL & \" OR (listall.example LIKE \'%\" & strKeyword & \"%\')\"
if you would like to call the columns from the other table you should add similar LIKE clauses just using articals.Column where Column is the name of the column you would like to refer to.
oops How do I set the connection ?? it looks like this now strDSN = \"DRIVER={Microsoft Access Driver (*.mdb)};DBQ=\"&Server.MapPath(\"../db/media.mdb\") Set myConn = Server.CreateObject(\"ADODB.Connection\") myConn.Open strDSN
Set rs = myConn.Execute(strSQL) If Not (rs.BOF Or rs.EOF) Then
hi there im still a little stuck ;( I changed myConn.Open strDSN to rs.open strSQL, myConn is this correct ?? sorry if im taking a little long with it but I havnt tried this before ;( Guzzie
sorry about the :) it works now it just took me a little time to work it out but you are quite right it works fine :)
thanks very much :)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.