MySQL SELECT in SELECT-clause or in WHERE-clause in order to filter further

I’m trying to filter some data, but as the data comes from 2 tables in the database I have to union them together, permitting nulls from the second table as I always need to have any values available in the first table, due to this being a product database with some products having sub-combinations and some none. Thus far I’ve come up with using a Union to join the two tables together, but now I need a method to filter out the data using a WHERE clause; however: this is where I get stuck. I tried putting the union as a select statement in the FROM clause: no data returned, I tried to put it into the SELECT clause as a sub: no data returned…

Merge two table columns without join query

I am making project in Laravel. I have multiple tables of which two table are books and authors. Author has columns : -id -name -all_books(',' separated values) -recent_books Books has columns : -id -author_id(foreign key(from author table)) -title -genre -pages Now, i want to fetch all data of books. But instead of author_id i want … Read more