PHP mysqli SELECT * from my_table WHERE id = array_of_ids
I have been using this site for years now and this is the first time I'm asking a question here, so kinda scared right now :D
Here's what my problem is, I have got two tables. In table_a I got three columns and in table_b I got 5. So the setup right now looks something like this:
table_a
| r_id | foo | bar |
+------+-------+-----+
| 1 | dude | 5 |
+------+-------+-----+
| 2 | homie | 6 |
+------+-------+-----+
| 3 | bro | 7 |
+------+-------+-----+
table_b
| id | ada | rea | lm | cor |
+----+-------+-----+------+------+
| 5 | ching | ink | jk | 32.4 |
+----+-------+-----+------+------+
| 1 | momo | pal | lmao | 95.5 |
+----+-------+-----+------+------+
| 6 | mama | pen | lol | 26.9 |
+----+-------+-----+------+------+
| 4 | chac | pin | fun | 91.2 |
+----+-------+-----+------+------+
| 7 | chim | lap | funk | 82.4 |
+----+-------+-----+------+------+
| 9 | cho | kil | fin | 38.1 |
+----+-------+-----+------+------+
Now what I'm trying to do is to get all the data from table_a and then only get lm
from table_b. I'm getting all the data from table_a like this:
SELECT r_id, foo, bar from table_a
I need to use the ids I get from bar
column to get lm
from table_b. So is there a way I can pass an array to only get the data based on the ids in an array? If not, then what would be the most efficient way to get those?
The output I'm expecting is jk, lol, funk
.
Would appreciate any help, thanks!
php mysql mysqli
add a comment |
I have been using this site for years now and this is the first time I'm asking a question here, so kinda scared right now :D
Here's what my problem is, I have got two tables. In table_a I got three columns and in table_b I got 5. So the setup right now looks something like this:
table_a
| r_id | foo | bar |
+------+-------+-----+
| 1 | dude | 5 |
+------+-------+-----+
| 2 | homie | 6 |
+------+-------+-----+
| 3 | bro | 7 |
+------+-------+-----+
table_b
| id | ada | rea | lm | cor |
+----+-------+-----+------+------+
| 5 | ching | ink | jk | 32.4 |
+----+-------+-----+------+------+
| 1 | momo | pal | lmao | 95.5 |
+----+-------+-----+------+------+
| 6 | mama | pen | lol | 26.9 |
+----+-------+-----+------+------+
| 4 | chac | pin | fun | 91.2 |
+----+-------+-----+------+------+
| 7 | chim | lap | funk | 82.4 |
+----+-------+-----+------+------+
| 9 | cho | kil | fin | 38.1 |
+----+-------+-----+------+------+
Now what I'm trying to do is to get all the data from table_a and then only get lm
from table_b. I'm getting all the data from table_a like this:
SELECT r_id, foo, bar from table_a
I need to use the ids I get from bar
column to get lm
from table_b. So is there a way I can pass an array to only get the data based on the ids in an array? If not, then what would be the most efficient way to get those?
The output I'm expecting is jk, lol, funk
.
Would appreciate any help, thanks!
php mysql mysqli
try where IN(array of ids)
– Devsi Odedra
Nov 13 '18 at 7:11
1
It's probably better to useinner join
for the solution
– Eugene Anisiutkin
Nov 13 '18 at 7:14
You should inner join
– Gufran Hasan
Nov 13 '18 at 7:15
If you want to stick to using an array and an in clause - then it's a duplicate of stackoverflow.com/questions/907806/…
– Nigel Ren
Nov 13 '18 at 7:25
add a comment |
I have been using this site for years now and this is the first time I'm asking a question here, so kinda scared right now :D
Here's what my problem is, I have got two tables. In table_a I got three columns and in table_b I got 5. So the setup right now looks something like this:
table_a
| r_id | foo | bar |
+------+-------+-----+
| 1 | dude | 5 |
+------+-------+-----+
| 2 | homie | 6 |
+------+-------+-----+
| 3 | bro | 7 |
+------+-------+-----+
table_b
| id | ada | rea | lm | cor |
+----+-------+-----+------+------+
| 5 | ching | ink | jk | 32.4 |
+----+-------+-----+------+------+
| 1 | momo | pal | lmao | 95.5 |
+----+-------+-----+------+------+
| 6 | mama | pen | lol | 26.9 |
+----+-------+-----+------+------+
| 4 | chac | pin | fun | 91.2 |
+----+-------+-----+------+------+
| 7 | chim | lap | funk | 82.4 |
+----+-------+-----+------+------+
| 9 | cho | kil | fin | 38.1 |
+----+-------+-----+------+------+
Now what I'm trying to do is to get all the data from table_a and then only get lm
from table_b. I'm getting all the data from table_a like this:
SELECT r_id, foo, bar from table_a
I need to use the ids I get from bar
column to get lm
from table_b. So is there a way I can pass an array to only get the data based on the ids in an array? If not, then what would be the most efficient way to get those?
The output I'm expecting is jk, lol, funk
.
Would appreciate any help, thanks!
php mysql mysqli
I have been using this site for years now and this is the first time I'm asking a question here, so kinda scared right now :D
Here's what my problem is, I have got two tables. In table_a I got three columns and in table_b I got 5. So the setup right now looks something like this:
table_a
| r_id | foo | bar |
+------+-------+-----+
| 1 | dude | 5 |
+------+-------+-----+
| 2 | homie | 6 |
+------+-------+-----+
| 3 | bro | 7 |
+------+-------+-----+
table_b
| id | ada | rea | lm | cor |
+----+-------+-----+------+------+
| 5 | ching | ink | jk | 32.4 |
+----+-------+-----+------+------+
| 1 | momo | pal | lmao | 95.5 |
+----+-------+-----+------+------+
| 6 | mama | pen | lol | 26.9 |
+----+-------+-----+------+------+
| 4 | chac | pin | fun | 91.2 |
+----+-------+-----+------+------+
| 7 | chim | lap | funk | 82.4 |
+----+-------+-----+------+------+
| 9 | cho | kil | fin | 38.1 |
+----+-------+-----+------+------+
Now what I'm trying to do is to get all the data from table_a and then only get lm
from table_b. I'm getting all the data from table_a like this:
SELECT r_id, foo, bar from table_a
I need to use the ids I get from bar
column to get lm
from table_b. So is there a way I can pass an array to only get the data based on the ids in an array? If not, then what would be the most efficient way to get those?
The output I'm expecting is jk, lol, funk
.
Would appreciate any help, thanks!
php mysql mysqli
php mysql mysqli
asked Nov 13 '18 at 7:09
Ather KhanAther Khan
82
82
try where IN(array of ids)
– Devsi Odedra
Nov 13 '18 at 7:11
1
It's probably better to useinner join
for the solution
– Eugene Anisiutkin
Nov 13 '18 at 7:14
You should inner join
– Gufran Hasan
Nov 13 '18 at 7:15
If you want to stick to using an array and an in clause - then it's a duplicate of stackoverflow.com/questions/907806/…
– Nigel Ren
Nov 13 '18 at 7:25
add a comment |
try where IN(array of ids)
– Devsi Odedra
Nov 13 '18 at 7:11
1
It's probably better to useinner join
for the solution
– Eugene Anisiutkin
Nov 13 '18 at 7:14
You should inner join
– Gufran Hasan
Nov 13 '18 at 7:15
If you want to stick to using an array and an in clause - then it's a duplicate of stackoverflow.com/questions/907806/…
– Nigel Ren
Nov 13 '18 at 7:25
try where IN(array of ids)
– Devsi Odedra
Nov 13 '18 at 7:11
try where IN(array of ids)
– Devsi Odedra
Nov 13 '18 at 7:11
1
1
It's probably better to use
inner join
for the solution– Eugene Anisiutkin
Nov 13 '18 at 7:14
It's probably better to use
inner join
for the solution– Eugene Anisiutkin
Nov 13 '18 at 7:14
You should inner join
– Gufran Hasan
Nov 13 '18 at 7:15
You should inner join
– Gufran Hasan
Nov 13 '18 at 7:15
If you want to stick to using an array and an in clause - then it's a duplicate of stackoverflow.com/questions/907806/…
– Nigel Ren
Nov 13 '18 at 7:25
If you want to stick to using an array and an in clause - then it's a duplicate of stackoverflow.com/questions/907806/…
– Nigel Ren
Nov 13 '18 at 7:25
add a comment |
6 Answers
6
active
oldest
votes
You should be looking at using a JOIN to link the two tables together in 1 query...
SELECT r_id, foo, bar, lm
FROM table_a
JOIN table_b on bar = id
Although you can do almost anything in PHP - SQL can make your life so much easier so worth taking some time to have a play with it.
– Nigel Ren
Nov 13 '18 at 7:27
add a comment |
Why not join?
select group_concat(lm) as lm_list
from table_b b
inner join table_a a on b.id = a.bar
You can use the GROUP_CONCAT() function, with this you would get jk, lol, funk
otherwise you would get 3 rows each of one lm
value,
add a comment |
try inner join
SELECT a.r_id, a.foo, a.bar, b.lm from table_a as a inner join table_b as b on b.id=a.bar
add a comment |
For that you can try WHERE IN feature of SQL.
SELECT lm from table_b WHERE id IN(ARRAY_OF_IDS)
Or you can also use join to achieve this
Select tale_a.*, tale_b.lm from tale_a inner join table_b ON tale_a.bar=tale_b.id
Thanks! that was pretty quick. So how would I do it using PHP. $bar_ids = array(5,6,7) $query = 'SELECT lm from table_b WHERE id IN($bar_ids)' and then run the query ?
– Ather Khan
Nov 13 '18 at 7:14
Yes, you can use this variable in it. $query = 'SELECT lm from table_b WHERE id IN($bar_ids)'. Or if bar is related with table_b id column then you can use joins too.
– Kamal Paliwal
Nov 13 '18 at 7:17
Thanks!! I tried Nigel's solution and it worked as expected. However, I'm going to keep this array thing in mind for future stuff. Thanks once again!
– Ather Khan
Nov 13 '18 at 7:28
add a comment |
I assume that you have array of IDs having IDs.
So first make a comma separated string of that array of IDs like this:
ids_str = implode("," $ARRAY_OF_IDS);
and then use that ids_str
in IN
os mysql query like below:
SELECT lm from table_b WHERE id IN( ids_str )
add a comment |
You can use INNER JOIN
SELECT tale_a.r_id, tale_a.foo, tale_a.bar ,table_b.lm
FROM tale_a
INNER JOIN table_b
ON tale_a.bar=table_b.id
Note: It returns all columns from table_a
and only one column from table_b
Resultant Output:
| r_id | foo | bar | lm |
+------+-------+-----+-----+
| 1 | dude | 5 | jk |
+------+-------+-----+-----+
| 2 | homie | 6 |lol |
+------+-------+-----+-----+
| 3 | bro | 7 |funk |
+------+-------+-----+-----+
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275633%2fphp-mysqli-select-from-my-table-where-id-array-of-ids%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
6 Answers
6
active
oldest
votes
6 Answers
6
active
oldest
votes
active
oldest
votes
active
oldest
votes
You should be looking at using a JOIN to link the two tables together in 1 query...
SELECT r_id, foo, bar, lm
FROM table_a
JOIN table_b on bar = id
Although you can do almost anything in PHP - SQL can make your life so much easier so worth taking some time to have a play with it.
– Nigel Ren
Nov 13 '18 at 7:27
add a comment |
You should be looking at using a JOIN to link the two tables together in 1 query...
SELECT r_id, foo, bar, lm
FROM table_a
JOIN table_b on bar = id
Although you can do almost anything in PHP - SQL can make your life so much easier so worth taking some time to have a play with it.
– Nigel Ren
Nov 13 '18 at 7:27
add a comment |
You should be looking at using a JOIN to link the two tables together in 1 query...
SELECT r_id, foo, bar, lm
FROM table_a
JOIN table_b on bar = id
You should be looking at using a JOIN to link the two tables together in 1 query...
SELECT r_id, foo, bar, lm
FROM table_a
JOIN table_b on bar = id
answered Nov 13 '18 at 7:16
Nigel RenNigel Ren
25.5k61832
25.5k61832
Although you can do almost anything in PHP - SQL can make your life so much easier so worth taking some time to have a play with it.
– Nigel Ren
Nov 13 '18 at 7:27
add a comment |
Although you can do almost anything in PHP - SQL can make your life so much easier so worth taking some time to have a play with it.
– Nigel Ren
Nov 13 '18 at 7:27
Although you can do almost anything in PHP - SQL can make your life so much easier so worth taking some time to have a play with it.
– Nigel Ren
Nov 13 '18 at 7:27
Although you can do almost anything in PHP - SQL can make your life so much easier so worth taking some time to have a play with it.
– Nigel Ren
Nov 13 '18 at 7:27
add a comment |
Why not join?
select group_concat(lm) as lm_list
from table_b b
inner join table_a a on b.id = a.bar
You can use the GROUP_CONCAT() function, with this you would get jk, lol, funk
otherwise you would get 3 rows each of one lm
value,
add a comment |
Why not join?
select group_concat(lm) as lm_list
from table_b b
inner join table_a a on b.id = a.bar
You can use the GROUP_CONCAT() function, with this you would get jk, lol, funk
otherwise you would get 3 rows each of one lm
value,
add a comment |
Why not join?
select group_concat(lm) as lm_list
from table_b b
inner join table_a a on b.id = a.bar
You can use the GROUP_CONCAT() function, with this you would get jk, lol, funk
otherwise you would get 3 rows each of one lm
value,
Why not join?
select group_concat(lm) as lm_list
from table_b b
inner join table_a a on b.id = a.bar
You can use the GROUP_CONCAT() function, with this you would get jk, lol, funk
otherwise you would get 3 rows each of one lm
value,
answered Nov 13 '18 at 7:16
Used_By_AlreadyUsed_By_Already
22.8k21938
22.8k21938
add a comment |
add a comment |
try inner join
SELECT a.r_id, a.foo, a.bar, b.lm from table_a as a inner join table_b as b on b.id=a.bar
add a comment |
try inner join
SELECT a.r_id, a.foo, a.bar, b.lm from table_a as a inner join table_b as b on b.id=a.bar
add a comment |
try inner join
SELECT a.r_id, a.foo, a.bar, b.lm from table_a as a inner join table_b as b on b.id=a.bar
try inner join
SELECT a.r_id, a.foo, a.bar, b.lm from table_a as a inner join table_b as b on b.id=a.bar
answered Nov 13 '18 at 7:15
Bhargav ChudasamaBhargav Chudasama
4,3452925
4,3452925
add a comment |
add a comment |
For that you can try WHERE IN feature of SQL.
SELECT lm from table_b WHERE id IN(ARRAY_OF_IDS)
Or you can also use join to achieve this
Select tale_a.*, tale_b.lm from tale_a inner join table_b ON tale_a.bar=tale_b.id
Thanks! that was pretty quick. So how would I do it using PHP. $bar_ids = array(5,6,7) $query = 'SELECT lm from table_b WHERE id IN($bar_ids)' and then run the query ?
– Ather Khan
Nov 13 '18 at 7:14
Yes, you can use this variable in it. $query = 'SELECT lm from table_b WHERE id IN($bar_ids)'. Or if bar is related with table_b id column then you can use joins too.
– Kamal Paliwal
Nov 13 '18 at 7:17
Thanks!! I tried Nigel's solution and it worked as expected. However, I'm going to keep this array thing in mind for future stuff. Thanks once again!
– Ather Khan
Nov 13 '18 at 7:28
add a comment |
For that you can try WHERE IN feature of SQL.
SELECT lm from table_b WHERE id IN(ARRAY_OF_IDS)
Or you can also use join to achieve this
Select tale_a.*, tale_b.lm from tale_a inner join table_b ON tale_a.bar=tale_b.id
Thanks! that was pretty quick. So how would I do it using PHP. $bar_ids = array(5,6,7) $query = 'SELECT lm from table_b WHERE id IN($bar_ids)' and then run the query ?
– Ather Khan
Nov 13 '18 at 7:14
Yes, you can use this variable in it. $query = 'SELECT lm from table_b WHERE id IN($bar_ids)'. Or if bar is related with table_b id column then you can use joins too.
– Kamal Paliwal
Nov 13 '18 at 7:17
Thanks!! I tried Nigel's solution and it worked as expected. However, I'm going to keep this array thing in mind for future stuff. Thanks once again!
– Ather Khan
Nov 13 '18 at 7:28
add a comment |
For that you can try WHERE IN feature of SQL.
SELECT lm from table_b WHERE id IN(ARRAY_OF_IDS)
Or you can also use join to achieve this
Select tale_a.*, tale_b.lm from tale_a inner join table_b ON tale_a.bar=tale_b.id
For that you can try WHERE IN feature of SQL.
SELECT lm from table_b WHERE id IN(ARRAY_OF_IDS)
Or you can also use join to achieve this
Select tale_a.*, tale_b.lm from tale_a inner join table_b ON tale_a.bar=tale_b.id
edited Nov 13 '18 at 7:21
answered Nov 13 '18 at 7:13
Kamal PaliwalKamal Paliwal
750310
750310
Thanks! that was pretty quick. So how would I do it using PHP. $bar_ids = array(5,6,7) $query = 'SELECT lm from table_b WHERE id IN($bar_ids)' and then run the query ?
– Ather Khan
Nov 13 '18 at 7:14
Yes, you can use this variable in it. $query = 'SELECT lm from table_b WHERE id IN($bar_ids)'. Or if bar is related with table_b id column then you can use joins too.
– Kamal Paliwal
Nov 13 '18 at 7:17
Thanks!! I tried Nigel's solution and it worked as expected. However, I'm going to keep this array thing in mind for future stuff. Thanks once again!
– Ather Khan
Nov 13 '18 at 7:28
add a comment |
Thanks! that was pretty quick. So how would I do it using PHP. $bar_ids = array(5,6,7) $query = 'SELECT lm from table_b WHERE id IN($bar_ids)' and then run the query ?
– Ather Khan
Nov 13 '18 at 7:14
Yes, you can use this variable in it. $query = 'SELECT lm from table_b WHERE id IN($bar_ids)'. Or if bar is related with table_b id column then you can use joins too.
– Kamal Paliwal
Nov 13 '18 at 7:17
Thanks!! I tried Nigel's solution and it worked as expected. However, I'm going to keep this array thing in mind for future stuff. Thanks once again!
– Ather Khan
Nov 13 '18 at 7:28
Thanks! that was pretty quick. So how would I do it using PHP. $bar_ids = array(5,6,7) $query = 'SELECT lm from table_b WHERE id IN($bar_ids)' and then run the query ?
– Ather Khan
Nov 13 '18 at 7:14
Thanks! that was pretty quick. So how would I do it using PHP. $bar_ids = array(5,6,7) $query = 'SELECT lm from table_b WHERE id IN($bar_ids)' and then run the query ?
– Ather Khan
Nov 13 '18 at 7:14
Yes, you can use this variable in it. $query = 'SELECT lm from table_b WHERE id IN($bar_ids)'. Or if bar is related with table_b id column then you can use joins too.
– Kamal Paliwal
Nov 13 '18 at 7:17
Yes, you can use this variable in it. $query = 'SELECT lm from table_b WHERE id IN($bar_ids)'. Or if bar is related with table_b id column then you can use joins too.
– Kamal Paliwal
Nov 13 '18 at 7:17
Thanks!! I tried Nigel's solution and it worked as expected. However, I'm going to keep this array thing in mind for future stuff. Thanks once again!
– Ather Khan
Nov 13 '18 at 7:28
Thanks!! I tried Nigel's solution and it worked as expected. However, I'm going to keep this array thing in mind for future stuff. Thanks once again!
– Ather Khan
Nov 13 '18 at 7:28
add a comment |
I assume that you have array of IDs having IDs.
So first make a comma separated string of that array of IDs like this:
ids_str = implode("," $ARRAY_OF_IDS);
and then use that ids_str
in IN
os mysql query like below:
SELECT lm from table_b WHERE id IN( ids_str )
add a comment |
I assume that you have array of IDs having IDs.
So first make a comma separated string of that array of IDs like this:
ids_str = implode("," $ARRAY_OF_IDS);
and then use that ids_str
in IN
os mysql query like below:
SELECT lm from table_b WHERE id IN( ids_str )
add a comment |
I assume that you have array of IDs having IDs.
So first make a comma separated string of that array of IDs like this:
ids_str = implode("," $ARRAY_OF_IDS);
and then use that ids_str
in IN
os mysql query like below:
SELECT lm from table_b WHERE id IN( ids_str )
I assume that you have array of IDs having IDs.
So first make a comma separated string of that array of IDs like this:
ids_str = implode("," $ARRAY_OF_IDS);
and then use that ids_str
in IN
os mysql query like below:
SELECT lm from table_b WHERE id IN( ids_str )
answered Nov 13 '18 at 7:22
PrakashGPrakashG
442514
442514
add a comment |
add a comment |
You can use INNER JOIN
SELECT tale_a.r_id, tale_a.foo, tale_a.bar ,table_b.lm
FROM tale_a
INNER JOIN table_b
ON tale_a.bar=table_b.id
Note: It returns all columns from table_a
and only one column from table_b
Resultant Output:
| r_id | foo | bar | lm |
+------+-------+-----+-----+
| 1 | dude | 5 | jk |
+------+-------+-----+-----+
| 2 | homie | 6 |lol |
+------+-------+-----+-----+
| 3 | bro | 7 |funk |
+------+-------+-----+-----+
add a comment |
You can use INNER JOIN
SELECT tale_a.r_id, tale_a.foo, tale_a.bar ,table_b.lm
FROM tale_a
INNER JOIN table_b
ON tale_a.bar=table_b.id
Note: It returns all columns from table_a
and only one column from table_b
Resultant Output:
| r_id | foo | bar | lm |
+------+-------+-----+-----+
| 1 | dude | 5 | jk |
+------+-------+-----+-----+
| 2 | homie | 6 |lol |
+------+-------+-----+-----+
| 3 | bro | 7 |funk |
+------+-------+-----+-----+
add a comment |
You can use INNER JOIN
SELECT tale_a.r_id, tale_a.foo, tale_a.bar ,table_b.lm
FROM tale_a
INNER JOIN table_b
ON tale_a.bar=table_b.id
Note: It returns all columns from table_a
and only one column from table_b
Resultant Output:
| r_id | foo | bar | lm |
+------+-------+-----+-----+
| 1 | dude | 5 | jk |
+------+-------+-----+-----+
| 2 | homie | 6 |lol |
+------+-------+-----+-----+
| 3 | bro | 7 |funk |
+------+-------+-----+-----+
You can use INNER JOIN
SELECT tale_a.r_id, tale_a.foo, tale_a.bar ,table_b.lm
FROM tale_a
INNER JOIN table_b
ON tale_a.bar=table_b.id
Note: It returns all columns from table_a
and only one column from table_b
Resultant Output:
| r_id | foo | bar | lm |
+------+-------+-----+-----+
| 1 | dude | 5 | jk |
+------+-------+-----+-----+
| 2 | homie | 6 |lol |
+------+-------+-----+-----+
| 3 | bro | 7 |funk |
+------+-------+-----+-----+
edited Nov 13 '18 at 7:45
answered Nov 13 '18 at 7:17
Gufran HasanGufran Hasan
3,53141326
3,53141326
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53275633%2fphp-mysqli-select-from-my-table-where-id-array-of-ids%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
try where IN(array of ids)
– Devsi Odedra
Nov 13 '18 at 7:11
1
It's probably better to use
inner join
for the solution– Eugene Anisiutkin
Nov 13 '18 at 7:14
You should inner join
– Gufran Hasan
Nov 13 '18 at 7:15
If you want to stick to using an array and an in clause - then it's a duplicate of stackoverflow.com/questions/907806/…
– Nigel Ren
Nov 13 '18 at 7:25