Possible Duplicate:
Combining several database table together?
I have following query and want done where with each value that is in $find
for name_re_all
, how is it in my query?
For example: name_re_all
is as:
ROW 3:
11111 22222 33333 44444
ROW 2:
55555 66666 77777
ROW 1:
88888 99999 112233 445566
If value $find
was 11111
show all values row 3: 11111 22222 33333 44444
Or
If value $find
was 66666
show all values row 2: 55555 66666 77777
Or
If value $find
was 33333
show all values row 3: 11111 22222 33333 44444
Or
If value $find
was 778899
show all values row 1: 88888 99999 112233 445566
Or
and ...
$query = $this -> db -> query('
SELECT
@rownum := @rownum + 1 rownum,
tour_foreign.id,
tour_foreign.name,
tour_foreign.airline,
MIN(tour_foreign_residence.name_re) AS name_re,
tour_foreign.service,
tour_foreign.date_go,
tour_foreign.date_back,
tour_foreign.term,
tour_foreign.useradmin_submit,
tour_foreign.date_submit,
GROUP_CONCAT( tour_foreign_residence.name_re
ORDER BY tour_foreign_residence.name_re
SEPARATOR "، "
) AS name_re_all
FROM tour_foreign
INNER JOIN tour_foreign_residence
ON ( tour_foreign.id = tour_foreign_residence.relation )
JOIN (SELECT @rownum := 0) r
WHERE tour_foreign.name LIKE "%' . $find . '%"
GROUP BY tour_foreign.id
HAVING name_re_all LIKE "%' . $find . '%"'
);
My tables in database: