Problem with selection in MySql

2

I'm starting this business and having difficulty selecting more than one table.

My selection command was as follows:

Table 01:

select * from veiculo;
|id_veiculo|modelo|cor|placa|chassi|renavam|combustivel|ano|hp|id_proprietario|id_uf|id_fabricante| 

|101001|Logan|Preta|JHE-3814|1234BFBF12|DF1234BR1234|GASOL/ALCOOL|2012|77|100|1|1010|
|101002|Corolla|Prata|JHJ-0007|2222BFBF22|DF4321BR4321|GASOLINA|2007|107|101|2|1011|
|101003|Strada|Vermelha|JHA-1221|3333BFBF11|MG0202BR4321|ALCOOL|2015|132|102|3|1012|

Table 02:

select * from fabricante;
|id_fabricante|nome|presidente|observacoes

|1010|Pedro Motta|RENAULT|Presidente da Renault em São Paulo e Rio de Janeiro|
|1011|Silvia Santos|TOYOTA|Presidente da Toyota em Brasília, Porto Alegre e Campo Grande|
|1012|Fausto Silva|FIAT|Presidente da Fiat no Brasil

This SQL is giving error:

SELECT t1.*,t2.* FROM veiculo t1, fabricante t2 
WHERE t1.id_fabricante= t2.id_fabricante AND t1.veiculo 
LIKE  "JHJ%" AND t1.ano <> 2000 AND t1.combustivel="GASOLINA" AND t2.presidente="TOYOTA";

ERROR 1054 (42S22): Unknown column 't1.veiculo' in 'where clause'

Where is the error?

    
asked by anonymous 14.04.2015 / 00:56

1 answer

1

The error is quite clear: the veiculo table does not have the veiculo column. You apparently wanted to search for t1.placa instead of t1.veiculo . The correct query would be:

SELECT t1.*,t2.*FROM veiculo t1, fabricante t2 
WHERE t1.id_fabricante = t2.id_fabricante AND t1.placa LIKE "JHJ%" 
AND t1.ano <> 2000 AND t1.combustivel = "GASOLINA" AND t2.presidente = "TOYOTA";
    
14.04.2015 / 01:06