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

Member Avatar for rajarajan2017

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');

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);

Member Avatar for rajarajan2017

The limitation I dont know! You have to check by inserting the datas.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.