dbTalk Databases Forums  

query hheeelp

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss query hheeelp in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bandul
 
Posts: n/a

Default query hheeelp - 04-25-2006 , 05:21 AM






Hi

need help
My english is not good so ill be short.
This is my database


create table customers
(
customerid int unsigned not null auto_increment primary key,
name char(40) not null,
address char(40) not null,
city char(20) not null,
state char(20),
zip char(10),
country char(20) not null
);

create table orders
(
orderid int unsigned not null auto_increment primary key,
customerid int unsigned not null,
amount float(6,2),
date date not null,
order_status char(10),
ship_name char(40) not null,
ship_address char(40) not null,
ship_city char(20) not null,
ship_state char(20),
ship_zip char(10),
ship_country char(20) not null
);

create table books
(
isbn char(13) not null primary key,
author char(30),
title char(60),
catid int unsigned,
price float(4,2) not null,
description varchar(255)
);

create table categories
(
catid int unsigned not null auto_increment primary key,
catname char(40) not null
);

create table order_items
(
orderid int unsigned not null,
isbn char(13) not null,
item_price float(4,2) not null,
quantity tinyint unsigned not null,
primary key (orderid, isbn)
);

The question is how to make a query to get order list of books from specific
customer.
example: John ordered LoR1 j.r.r.tolkien 20 $ The best book ever
LoR2 j.rr Tolkirn 20$ The second best
book
Php mySql Welling 25$ The good book of
php

Please help
Thanks Ivan



Reply With Quote
  #2  
Old   
Jens
 
Posts: n/a

Default Re: query hheeelp - 04-25-2006 , 06:21 AM






Hi,

try this one here:


Select Cust.name,b.author,Cat.catname,oi.item_price,b.des cription
Quote:
From Customers Cust
INNER JOIN Orders O
ON O.CUstomerId = Cust.CustomerId
INNER JOIN Order_Items oi
ON oi.OrderId = O.OrderId
INNER JOIN books b
ON b.Isbn = oi.Isbn
INNER JOIN Categories Cat
ON c.Catid = B.catid

HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---



Reply With Quote
  #3  
Old   
Bandul
 
Posts: n/a

Default Re: query hheeelp - 04-26-2006 , 04:37 AM



Thanks Jens
"Jens" <Jens (AT) sqlserver2005 (DOT) de> wrote

Quote:
Hi,

try this one here:


Select Cust.name,b.author,Cat.catname,oi.item_price,b.des cription
From Customers Cust
INNER JOIN Orders O
ON O.CUstomerId = Cust.CustomerId
INNER JOIN Order_Items oi
ON oi.OrderId = O.OrderId
INNER JOIN books b
ON b.Isbn = oi.Isbn
INNER JOIN Categories Cat
ON c.Catid = B.catid

HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---




Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.