SitePoint Sponsor |
|
User Tag List
Results 1 to 5 of 5
-
Oct 14, 2009, 02:53 #1
- Join Date
- Mar 2009
- Posts
- 226
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
selecting columns based on queries from three tables
table item has
item_name
.....
table bill has
bill_id
qty
.....
table bill_id has
date
.....
now my query is
"select p.item_name,c.qty,c.bill_id
from bill as c
JOIN items as p ON p.id=c.id
where p.category_name='$q'";
i also want to add another condition in where clause so tat it also checks date form bill_id table
how do i do it
-
Oct 14, 2009, 03:18 #2
What is the relationship between the bill_id table and the other two?
Guido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget
-
Oct 14, 2009, 03:23 #3
- Join Date
- Mar 2009
- Posts
- 226
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
bill will have a column bill_id which will have the same id(primary key) as tat of bill_id
-
Oct 14, 2009, 03:27 #4
Calling a column 'date' might result in errors, since it is a reserved word in MySQL. Unless you don't mind putting it in backticks each time you use it.
Guido - Community Team Leader
The Votes Are In: The Winners of the 2013 Community Awards are...
Blog - Free Flash Slideshow Widget
-
Oct 16, 2009, 02:34 #5
- Join Date
- Mar 2009
- Posts
- 226
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thanks
it worked gr8
Bookmarks