Selecionar Na Tabela
#1
Posted 26/07/2004, 14:59
TABELA CLIENTES_TIPOS
codigo
cod_cliente
cod_tipo
RESULTADO TABELA CLIENTES_TIPOS
codigo | cod_cliente | cod_tipo
1 | 1 | 1
2 | 1 | 3
3 | 1 | 5
Quero selecionar todos os clientes onde o código_tipo é igual a 1 e 5 por exemplo, como faço?
Abraços.
#2
Posted 26/07/2004, 15:01
select * from tabela where tipo in (1,5)ou
select * from tabela where tipo=1 or tipo=5
Mero mortal!
#3
Posted 26/07/2004, 15:08
#4
Posted 26/07/2004, 15:10
$res = mysql_query("SELECT clientes_tipos.*, clientes.* FROM clientes INNER JOIN clientes_tipos ON clientes_tipos.cod_cliente = clientes.cod_cliente WHERE clientes.cod_categoria = '$categoria' AND clientes_tipos.cod_tipo = '$pref1' AND clientes_tipos.cod_tipo = '$pref2' AND clientes_tipos.cod_tipo = '$pref3'");
Não está retornando nada, mesmo existindo estas informações na tabela.
Edição feita por: marciofr, 26/07/2004, 15:30.
#5
Posted 26/07/2004, 15:11
Você quer o cliente ?!?! Basta colocar outro filtro, não resolve?
select c.nome, t.* from tipo t, cliente c where c.cod_cliente=t.cod_cliente and tipo in (1,5)
Mero mortal!
#6
Posted 26/07/2004, 15:39
clientes_tipos.cod_tipo = '$pref1' AND clientes_tipos.cod_tipo = '$pref2' AND clientes_tipos.cod_tipo = '$pref3'
Existe alguma outra forma?
#7
Posted 26/07/2004, 16:30
Mero mortal!
0 user(s) are reading this topic
0 membro(s), 0 visitante(s) e 0 membros anônimo(s)