![]() |
data from two tables?
How i can get data from two tables at same time?
|
Use JOINS
|
Suppose I have two tables
In table 1 I have movie_id, movie_name In table_2 I have movie_id,movie_genre Now I want to know the the names of movie which belongs to particular genre ANSWER SELECT movie_name FROM table1 JOIN table2 USING (movie_id) WHERE movie_genre = 'some_genre' This is the example to get data from two tables Destination Wedding Photographer Top Wedding Photographers Wedding Photographer Hertfordshire |
Quote:
There are so many ways you might want to get data from two tables that it's hard to pin it down to one example. For example, suppose you wanted a list of all movie_genre's with a sub-list of the movies associated with that genre. And you want a genre to show even if there is currenly no movie in that genre. Code:
SELECT t1.movie_genre, t2.movie_name |
| All times are GMT +1. The time now is 09:31 PM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.