Welcome Guest, Not a member yet? Register   Sign In
SELECT 2 tables, proper syntax?
#1

[eluser]solid9[/eluser]
Before anything else I"m using MyISAM since my hosting don't support InnoDB.

I have two tables that has columns,

1st table: users_swap
and the columns are
Code:
usid,
us_id,
swap_id

note: us_id came from 'users' table.

2nd table: swap
and the columns are
Code:
swap_id,
date_posted,
offering,
seeking

I want to SELECT swap_id and offering columns from swap table.
Using a specific user_id from users_swap table

I hope I explained it clearly.
So what is the right SELECT syntax?

Thank you very very much in advanced.
#2

[eluser]Otemu[/eluser]
Check out the guide http://ellislab.com/codeigniter/user-gui...ecord.html

Here is an example joining two tables

$this->db->select('*');
$this->db->from('users_swap');
$this->db->join('swap', 'users_swap.swap_id = swap.swap_id');
$this->db->where('usid', 1);
$query = $this->db->get();

This basically joins both tables and selects a usid equal to 1 from the users_swap table




Theme © iAndrew 2016 - Forum software by © MyBB