I'm making a search engine in php and i use Mysql . I'm trying to search into 2 different kind of tables.A blog table and categories table.
I can't use UNION because tables doesn't have the same number of columns.
SELECT titre, description,url,'actualites' AS type
FROM cs_actualites
WHERE cs_actualites.description LIKE :pattern
OR cs_actualites.titre LIKE :pattern
SELECT
root.url rootUrl,
parent.url parentUrl,
child.url childUrl,
parent.titre parentTitle,
parent.description parentDesc,
child.titre childTitle,
child.description childDesc
FROM cs_categories root
LEFT JOIN cs_categories parent
ON root.id = parent.parent
LEFT JOIN cs_categories child
ON parent.id = child.parent
WHERE (root.description LIKE :pattern OR root.titre LIKE :pattern)
OR (parent.titre LIKE :pattern OR parent.description LIKE :pattern)
OR (child.titre LIKE :pattern OR child.description LIKE :pattern);
The both queries should results : a title , a description and an url. The 2nd query should results addionnaly many urls(for each category and sub_category).
How can i get result from those 2 queries into one ?
Thank you for helping :)