Ask the great God to answer the question of a database statement
SELECT ' id ', ' time ', ' title '
From ' Think_infor '
WHERE ' type ' like ' $k-% '
UNION All
SELECT ' id ', ' time ', ' title '
From ' Think_infor2 '
WHERE ' type ' like ' $k-% '
ORDER by ' time ' DESC
LIMIT 0,6
Use this statement to query the latest 6 information for Table 1 and table 2. But how do you tell which table the record is returned from?
Or what other methods can be implemented, do not want to query multiple times
------Solution--------------------
Can't you just write it yourself?
SELECT ' id ', ' time ', ' title ', ' Think_infor ' as Tbl_name
From ' Think_infor '
WHERE ' type ' like ' $k-% '
UNION
From ' Think_infor2 '
WHERE ' type ' like ' $k-% '
ORDER by ' time ' DESC
LIMIT 0,6
Added an output field tbl_name to differentiate the data source
Union All is changed to union to avoid duplicate records. No more sources, no repetition, no repetition.