Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rdl
Starting Member
25 Posts |
Posted - 2011-06-26 : 08:21:40
|
| Hi, I have the following code: $result = mysql_query("SELECT * FROM report WHERE ReportRef LIKE '%" . $search . "%' or Town LIKE '%" . $Town . "%' or Category LIKE '%" . $Category . "%' or ReportStatus LIKE '%" . $ReportStatus . "%' "); $result = mysql_query ("SELECT ID FROM reportperson WHERE ID LIKE '%" . $ID. "%');Can someone tell me how I can do the search from different tables as i am having errors when coming to display above results.Thanks,rdl |
|
|
rdl
Starting Member
25 Posts |
Posted - 2011-06-26 : 08:22:57
|
| Note that table 'reportperson' has ReportRef as a foreign key to connect it to table 'report'. |
 |
|
|
rdl
Starting Member
25 Posts |
Posted - 2011-06-26 : 09:12:21
|
| Problem solved :)$result = mysql_query (" SELECT * from report r INNER JOIN reportperson rpON r.ReportRef = rp.ReportRefINNER JOIN reportofficer roon rp.ReportRef = ro.ReportRefLEFT JOIN reportvehicle rvon r.ReportRef = rv.ReportRefWHERE (r.ReportRef LIKE '%" . $search . "%' orr.Town LIKE '%" . $Town . "%' or r.Category LIKE '%" . $Category . "%' orr.ReportStatus LIKE '%" . $ReportStatus . "%' orrp.ID LIKE '%" . $ID . "%')"); |
 |
|
|
|
|
|