Dan Cantir
Dan Cantir

Reputation: 177

mysql select from 2 tables as one value

I have 2 tables:

users

user_id | user_name  | user_avatar

and

events

event_id | event_name | event_avatar

i need a query that will select all avatars in one array, and then, i want to echo them all, as a photo gallery.

can anyone help me please ?

i've tried

SELECT e.event_avatar , u.user_avatar as img FROM events e ,users u ORDER BY e.id DESC LIMIT 0, 17"

Upvotes: 0

Views: 88

Answers (1)

Laurence
Laurence

Reputation: 10976

For the SQL bit it seems you want a Union:

Select
  event_avatar
From
  events
Union All
Select
  user_avatar
From
  users

Upvotes: 3

Related Questions