0

I have an array variable like this

$variable[] = $data['master_software_capability_id'];

How to use this array variable in SQL query

Is this the right way ?

SELECT * FROM software_capability where software_capability_id IN ($variable);
0

2 Answers 2

3

You need to implode the array to comma separated string

$variables_imploded = implode(",",$variable);

"SELECT * 
FROM software_capability 
where software_capability_id IN 
(".$variables_imploded.")";
Sign up to request clarification or add additional context in comments.

1 Comment

@Senthilkumar please accept this answer as accepted so it will be marked as solved
1

use JOIN or IMPLODE

$variables_joins = join(',',$variable);  

SELECT * FROM software_capability where software_capability_id IN ($variables_joins);

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.