简体   繁体   中英

select by id and specific column letter a-z

I have data like below , and I have array (3, 4, 8) mean id I have to get ,
is there a way I can use the array get rows by subject column letter a to z?

id | subject   
unsigned auto_increment | varchar(255)

id | subject     
3 | beck  
4 | agyness  
5 | zelta  
7 | bess
8 | green



for ($i=0; $i < count(id_array); $i++) {  
  ..
  select * from table where id = id_array[$i]  
}

This will select all the id's in the array and order them by subject

$someArray = array(1,5,6,7);

"SELECT * from table where id IN (".implode(",", $someArray).") order by subject ";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM