N
N
nezzard2015-02-11 16:01:15
SQL
nezzard, 2015-02-11 16:01:15

How to form SQL correctly?

Good afternoon, there are 2 tables
sites
-----
id
http
reward
time
and
users
------
id
user_id
time
site_id
You need to select SELECT * FROM sitesand

SELECT time_in_sec FROM sites, users WHERE sites.id = users.site_id

How to combine them so that all the information from the first request is displayed, and only that which is needed from the second, how to do this with one request?
I assume that $result[something] in one of them contains information on the second request, and in which there is none, they will be null

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2015-02-11
@FanatPHP

SELECT * FROM sites LEFT JOIN users ON sites.id = site_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question