i am asking about the max开发者_JS百科 number of querys in the page !
i have 6 querys in my script
select * from settings //my website settings
select * from articales where art_id = '' // topics
select * from tags // tags
select * from categories // categories
select * from sub_categories
so the big scripts like vbulletin and wordpress , etc
How many querys, almost ? !
i am sorry for my language but i want to know my querys is more ? or they good
to save my server health , i have more visitors
and please if any one can tell me , how i can get data from multiple tables in one query ?
Example :
i want get all data from posts and from tags
where post id equal '10'
thank you ..
Why are you fetching your entire database at once?
Anyway you can just select them all in a single query:
SELECT * FROM settings, articales, tags, categories, sub_categories ...
Of course you'll want to join them and group them in some way otherwise you'll simply have a huge recordset of mixed up junk.
Regarding your posts and tags join, something like this would make sense, though I have no idea how your tags and posts are related in your schema
SELECT * FROM posts LEFT JOIN tags on posts.tag_id = tags.tag_id WHERE posts.post_id = 10
If you have a many-to-one tags-to-posts assignment, look into FIND_IN_SET() for your query. Ex: FIND_IN_SET('b','a,b,c,d')
精彩评论