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

0

I have a single table of only one column with all the words in Portuguese. I want to make a Double or Triple Select and retrieve in every query all words with 'A' in the alias WordsComA, and all with 'B' in the Alias WordsComB.

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 get all of them 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'm 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 begin with the letter of the word and I make comparison via php. Until then, it's all right. But I want it when I have more words instead of searching one by one in the database to search all of the phrase separated by aliases that are the search words themselves.

The closest I came was the first example.

    
asked by anonymous 23.09.2017 / 01:31

0 answers