sql - Subquery used as expression doesn't work -


i have theses 3 tables created in postgres:

create table info_clients(id_client int(pk),name varchar(20), last_name varchar(20)); create table customer_request(id_request int(pk),client int(fk),product int(fk)); create table info_products(id_producto int(pk),description varchar(20),price int); 

and have next query:

show id's of clientes bought 10 expensive items (using subquery):

select id_client info_clients id_cliente=(  select client                      customer_request                      product=( select id_product                                      info_products                                      order price desc limit 10                                   )                  ); 

but keep getting message_ subquery used expression returned more 1 register, don't know doing wrong.

what @kordirko commented.
plus, joins faster , better in every respect (nested) in expressions.

select i.id_client  (    select id_product       info_products     order  price desc    limit  10    ) p join   customer_request r on c.product = p.id_product join   info_clients     on i.id_client = c.client; 

aslo, typo? id_cliente <-> id_client
more in manual on select.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -