I have this site for ads, and I have about 7 tables in MySql where all the data is stored. I have one main table called "ads".
The declaration table has a column called class_id. This is not a PC or key at all. This is just a number that is used to share table entries.
Example:
classifieds table: fordon table: id => 33 id => 12 classified_id => 10 classified_id => 10 ad_id => 'bmw_m3_92923'
This is linked above using the classic_id column.
Now in Q, I use this method to retrieve all the records. The WHERE column ad_id matches any of the values โโinside the array, called in this case $ ad_arr:
SELECT mt.*, fordon.*, boende.*, elektronik.*, business.*, hem_inredning.*, hobby.* FROM classified mt LEFT JOIN fordon ON fordon.classified_id = mt.classified_id LEFT JOIN boende ON boende.classified_id = mt.classified_id LEFT JOIN elektronik ON elektronik.classified_id = mt.classified_id LEFT JOIN business ON business.classified_id = mt.classified_id LEFT JOIN hem_inredning ON hem_inredning.classified_id = mt.classified_id LEFT JOIN hobby ON hobby.classified_id = mt.classified_id WHERE mt.ad_id IN ('$ad_arr')";
Is this good, or will it really lead to unnecessary information?
Check out this Q that I posted a couple of days ago. In the comments, HLGEM comments that this is wrong, etc. What do you think?
Another rookie; How to implement Count () here?
thanks
html sql database php mysql
user188962
source share