Got a query like this:
SELECT * FROM job WHERE status!=2 AND status!=3
UNION SELECT * FROM emp WHERE status!=2 AND status!=3
ORDER BY (id/popularity) DESC LIMIT {$from},$vpc
It works perfectly, but now can't identify where 开发者_StackOverflowfrom record is coming... Is there any way to identify from which table, the record is coming?
I guess you could try this:
SELECT *, 'job' as origin
FROM job
WHERE status!=2
AND status!=3
UNION SELECT *, 'emp' as origin
FROM emp
WHERE status!=2
AND status!=3
ORDER BY (id/popularity) DESC
LIMIT {$from},$vpc
This should add a field named origin to your results, containing a name of your choice to identify the table.
精彩评论