I have two MYSQL tables events and users. This is my events table:
id | 8
event | camping
This is my users table:
id | 1
event | camping, kayaking
FullName| John
How do i join the two tables together and print out the FullName?
I have two MYSQL tables events and users. This is my events table:
id | 8
event | camping
This is my users table:
id | 1
event | camping, kayaking
FullName| John
How do i join the two tables together and print out the FullName?
i think what You want to do is exactly this:
SELECT dbo.events.event, dbo.users.id, dbo.users.FullName
FROM dbo.events INNER JOIN
dbo.users ON dbo.users.event LIKE '%' + dbo.events.event + '%'
This will give You list with ID and FUllName of all people from table users that has camping in their event column.
for example I have two tables USERS and EVENTS. My USERS table is (ID, USERNAME) and my EVENTS table is (ID,USERID, EVENT) and I want to join both tables and show full info about users and their events in PHP. My code could be
PDO::ERRMODE_EXCEPTION]); $sql = "select us.*, ev.* from events ev left outer join users us on us.ID = ev.USERID"; $recordset = $dsn->query($query); foreach($recordset as $row) ///goes your loop where your fetch all necessary fields } catch(PDOException $ex) { echo $ex->getMessage(); } catch(Exception $ex) { echo $ex->getMessage(); } ?>`
select us.*, ev.* from event ev left outer join users us on us.id (or else) = ev.id (or else)
if records from the left table are not always match records from the right table otherwise:
select us.*, ev.* from event ev inner join users us on us.id (or else) = ev.id (or else)
joining by key fields if your tables
Hope it will help