Make two or more Select with Aliases in the query to generate a separate array

Asked

Viewed 96 times

0

I have a single column table with all the words in English. I want to do a double or triple Select and recover in each query all words with 'A' in alias Palavrascoma, and all with 'B' in Alias Palavrascomb.

When I recover in PHP it is coming like this

[ComecaComA] => agua
[ComecaComB] => 
[ComecaComA] => agora
[ComecaComB] => 

and only when it starts with 'B' comes

[ComecaComA] => 
[ComecaComB] => bola
[ComecaComA] => 
[ComecaComB] => bolado

I want to catch them all with 'A' first in array 0 for example and then all with 'B' in array 1.

"select if( w.word like 'a%', w.word, '') as ComecaComA,
       if(w.word like 'b%', w.word, '') as ComecaComB

from teste as w limit 0,400000"

I am creating a word broker, and it works word for word with the following query:

$wd = substr($palavra,0,1);

$palavras = "select `wd` from ptbr where left (`wd`, 1) = '$wd'";

It returns me all to words that start with the letter of the word and I make comparison via php. So far it’s all right. But I want when you have more words instead of searching one by one in the database to find all of the phrase separated by aliases that are the search words themselves.

The closest I came was the first example.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.