Hey,
I'm writing a search function, and all was going well but now I'm stuck. Please bare with me, I'm new.
The form. There are three checkboxes, which select which categories can be returned in the search (ie. if checkbox1 is checked category one is include, if checkbox 2 is checked, it's included as well, etc.). The rest is pretty standard.
The three categories are determined by the last four characters of the value in one column. Records that have "abcd" as the last four characters in columnA are one category, records with something else are another, etc. So...rather than having to process that string of each record for the search, I sorted the different categories into three separate tables. When the checkbox for that category is checked, it's table is added to the query. Easy enough.
So I came up with a query like this:
" SELECT * FROM tableA,tableB,tableC WHERE tableA.columnA LIKE '%$query%' OR tableB.columnA LIKE '%$query%' OR
tableC.columnA "
Worked fine. Now I have to sort, and that's where I'm stuck.
I want to sort by columnA, but if I use:
" SELECT * FROM tableA,tableB,tableC WHERE tableA.columnA LIKE '%$query%' OR tableB.columnA LIKE '%$query%' OR
tableC.columnA ORDER BY columnA"
I get an error: "columnA is ambigous". It doesn't know which columnA to sort by. So I need to combine the result of those searches, then search by the common column.
Any ideas?
Thanks, in advance.