Mysql SELECT * from table where (something that from a multidimentional array)

Hello forums

is ti possible to query a mysql db but the WHERE belongs to a multidimentional array :

$doors = Array
(

[links] => Array

 (

[0] => Array

     (

[text] => home

     )

 )

)

SELECT *FROM doors WHERE links = multidimentionalarray([text] => home) //

as you see “text” is not right after “links” is after the element “0”

so I can not use WHERE link.text because the 0

any one? please :slight_smile:

Query can be only string. You cannot add array to a string.
You can compose query string from your array.

But at first you need to know which query you want.

hello Shrapnel,

I want to query something like this:

SELECT *FROM doors WHERE links.text = ‘at’ LIMIT 1

but the array is not in the form of:

[links] => Array
(
[text] => home
)
)

like that I could use: where links.text = ‘at’

But my array has a [0], so is not accepting the links.text

thanks for your help

It is quite complicated task.
From where you’ve get this array?

thanks for your help, what i am going to do is set a limit of 100 (I only need like 5), SELECT *FROM doors WHERE links != ‘’ LIMIT 100

then filter the result.

Do you need every field in the table in the results set? If not just select the fields required.

You can use an IN statement, and prefill the in statement with the individual array values in php. Something like:

$numbers = array( 1, 4, 7, 11, 22 );

$sql = “SELECT * FROM doors WHERE id IN ( " . implode( “,”, $numbers ) . " )”;

I should note though that the larger the array, the slower your query may execute.