|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Help with Join Query
Hi gang. I have searched and searched and cannot figure out what/why this query is wrong.
Code:
$query = "(SELECT * FROM table1 WHERE keywords LIKE '%".$term."%') UNION ALL (SELECT * FROM table2 WHERE keywords LIKE '%".$term."%')"; Table 1 and Table 2 are not relational. They are essentially two data storage tables. I want to search both to see if either match the related keyword (term). But my query fails. If I run each query by itself, it works fine. |
|
#2
|
|||
|
|||
|
What do you mean 'fails'? Are you getting an error, or just unexpected result sets?
__________________
"A pawn is the most important piece on the chessboard -- to a pawn" |
|
#3
|
|||
|
|||
|
Quote:
I keep getting my 'die' results. |
|
#4
|
|||
|
|||
|
I'm guessing you're not selecting the same number of columns from each of your selects. Use this to get MySQL's error message; it'll give you a more specific idea of the problem.
PHP Code:
|
|
#5
|
|||
|
|||
|
Great! You are correct. Ok I was doing a select *, so alternatively if I manually selected an equal number of columns, it should work.
Awesome, off to try it! |
|
#6
|
|||
|
|||
|
That was it. Thanks for the quick response/help.
|
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Help with Join Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|