Answer the question
In order to leave comments, you need to log in
How to pull data from a table according to data from where of another table?
There is a request
select * from items where prise > (select sell_prise from results where items_id = 1) and id = 1;
. Answer the question
In order to leave comments, you need to log in
you have written
SELECT * # - выбрать все *(звездочка)
FROM items # - из таблицы items
WHERE # - где
prise > # - цена prise больше(пишется price правильно)
(
# Этот подзапрос вернет число которое сверяется с prise
SELECT sell_prise # - выбрать sell_prise (sell_priсe правильно)
FROM results # - из таблицы results
WHERE items_id = 1 # - где items_id (в таблице results) = 1
)
AND id = 1; # - и id (в таблице items ) = 1
SELECT *
FROM items LEFT JOIN results ON items.id = results.items_id
WHERE items.prise > results.sell_prise
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question