R
R
Roquie2014-10-13 18:49:05
PHP
Roquie, 2014-10-13 18:49:05

How to correlate the result of the selection to the identifier from the where in (...) condition?

this is the request

SELECT field1, field2 FROM data WHERE user_id IN ('123', '680')

will return a mess of all the information where these 2 identifiers meet.
How to make it so that the output is something like this (in one request):
$result = [
   123 => [
       'field1' => 'foo3',
       'field2' => 'bar4'
   ],
   680 => [
       'field1' => 'foo5',
       'field2' => 'bar6'
   ]
];

I do not want a bunch of selects to be executed in a loop, there is a lot of information. So I took out id-shki and ... asked myself this question :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Zelenin, 2014-10-13
@zelenin

make a request, then in php iterate over everything with the compilation of a new array

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question