dbTalk Databases Forums  

advice on sql querys?

comp.databases comp.databases


Discuss advice on sql querys? in the comp.databases forum.



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

Default advice on sql querys? - 02-18-2004 , 09:39 PM






I'm having a bit of a brain jam. These are the sql statements I want
to run but I can't quite figure it out:

1. Be able to return all entries in the ITEM table with the
attributes, but sorted by a particular ITEM_ATTRIBUTES.NAME (Sort by
Color).

2. Search by attribute value.

3. Be able to return the item with it's attributes all on one row. E.g
itemid title, description, name1, value1, name2, value2, name3,
value3
1, shirt, really nice shirt, color, red, color, blue,
size, s, size, m
(or something similar).

Sub-selects cannot be used.

Here's the tables:

ITEM
--------
ITEMID
TITLE
DESCRIPTION

ITEM_ATTRIBUTES
------------------
ITEMID
NAME
VALUE

Example:
ITEM
-------------
ITEMID, TITLE, DESCRIPTION
1 , shirt , really nice shirt

ITEM_ATTRIBUTES
-----------------
ITEMID, NAME, VALUE
1 , Color, Red
1 , Color, Blue
1 , Size, S
1 , Size, M

Thanks for your thoughts.

Reply With Quote
  #2  
Old   
Ed prochak
 
Posts: n/a

Default Re: advice on sql querys? - 02-19-2004 , 01:21 PM






Justin Kennedy <ng (AT) NO_SPAMmaritimesource (DOT) ca> wrote

Quote:
I'm having a bit of a brain jam. These are the sql statements I want
to run but I can't quite figure it out:

1. Be able to return all entries in the ITEM table with the
attributes, but sorted by a particular ITEM_ATTRIBUTES.NAME (Sort by
Color).

2. Search by attribute value.

3. Be able to return the item with it's attributes all on one row. E.g
itemid title, description, name1, value1, name2, value2, name3,
value3
1, shirt, really nice shirt, color, red, color, blue,
size, s, size, m
(or something similar).

Sub-selects cannot be used.

Here's the tables:

ITEM
--------
ITEMID
TITLE
DESCRIPTION

ITEM_ATTRIBUTES
------------------
ITEMID
NAME
VALUE

Example:
ITEM
-------------
ITEMID, TITLE, DESCRIPTION
1 , shirt , really nice shirt

ITEM_ATTRIBUTES
-----------------
ITEMID, NAME, VALUE
1 , Color, Red
1 , Color, Blue
1 , Size, S
1 , Size, M

Thanks for your thoughts.
Hmm. Are mid term exams coming up already?

You use the buzzwords like attribute and subselect but don't even know
when to use a WHERE Clause???

okay some hints:
1 look up ORDER BY
2 look up WHERE clause
2 look up JOIN and SELECT clauses

You did at least buy the textbook didn't you?

HTH (I really do),
Ed


Reply With Quote
  #3  
Old   
--CELKO--
 
Posts: n/a

Default Re: advice on sql querys? - 02-19-2004 , 02:00 PM



This is a report and not a query; do it in the front end where it belongs.

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.