0

Hello ppl,

I have a mysql db and i want to know how is better to use queryes on my website

in the table favorite i have many rows with id (some numbers..) and fav ( img1 img2 img3 img4 img5 etc..)

and a table named img where the first id is img1 for example

so wich metod is better to use for getting all img info from the db:

1: using SELECT * FROM img WHERE id='img1' || id='img2' || id='img3'...etc
(and here how many || or && i can use in one query ?! because the row FAV in table FAVORITE can have a large number of favorite images)

2: or using queries for each img: SELECT * FROM img WHERE id='img1'
$img1info = dbquery..
SELECT * FROM img WHERE id='img2'
$img2info = dbquery..
etc........

wich method is better? or is an easyer way to get info for all the images located in the fav row?! from the favorite table..??
sorry for my bad english... please help me , even if you are not an expert suggestions are god for me thanks a lot

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by Member 784670
1

You can use like below

SELECT * FROM img WHERE id IN ('img1','img2','img3','img4'); (or)
SELECT * FROM img WHERE id NOT IN ('img5','img6');
0

thanks rajaranjan07 your code is good for me but i'm wondering how many img i can put in one query 1000..2000 ? this is my real problem

SELECT * FROM img WHERE id IN ('img1','img2','img3','img4'....,'img104'.....,'img1051'..etc);

0

Kindly help me ... i want do one project on Equipment Maitanence in PHP language.. What are things i have to learn?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.