I have code in PHP and i want it to make only sql like
table content
word size place
small 10 home
large 18 outside
dog 11 home
cat 6 home
dog 20 outside
small 99 outside
The PHP code isnt absolutly correct, but you will see what i need.
$input = array("small", "dog");
$place2 = array();
$sql1 = SELECT word,size,place FROM TAB WHERE word = input[0];
$sql2 = SELECT word,size,place FROM TAB WHERE word = input[1];
if ((($sql1['size'] - $sql2['size']) == 1) && ($sql1['place'] == $sql2['place']) ) {
$place2[] = $sql2['place'].$sql2['word'].$sql1['word'];
}
and output $place2[] like a result of query
Is it possible to make this purely in sql without using PHP code? I mean just make some query (Tquery) that will compare values from two different queries and output array of place and word values that will accept that if statement? i need that because db is faster than php and i have a lot of rows