Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
outputting "word" instead of (number) with WHERE clause jewel="diamond"
Old 01-07-2011, 03:00 PM outputting "word" instead of (number) with WHERE clause jewel="diamond"
Junior Talker

Posts: 3
Trades: 0
I have two tables like the below.
Code:
jewelry

(id) jewel
(1)   diamond
(2)   "gold"

jewels

(jewel1)  (jewel2)
(1)         (2)
The result of the code1 below outputs diamondRelated (2).
Code:
code1

SELECT
jewel2 as diamondRelated
FROM jewels
left join jewelry on id=jewel1
WHERE
jewel="diamond"
I like to output diamondRelated with the word "gold" instead of the number (2).

The result of the code2 below outputs diamondRelated diamond instead of "gold".
Code:
code2

SELECT
jewel as diamondRelated
FROM jewels
left join jewelry on id=jewel1
WHERE
jewel="diamond"
The code3 below is another trial.
Since I add left join jewelry on id=jewel2 for connecting (2) to "gold",
It causes an ERROR.
Code:
code3

SELECT
jewel as diamondRelated
FROM jewels
left join jewelry on id=jewel1
left join jewelry on id=jewel2
WHERE
jewel="diamond"

Last edited by dNoopy; 01-07-2011 at 05:36 PM..
dNoopy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-14-2011, 02:27 PM Re: outputting "word" instead of (number) with WHERE clause jewel="diamond"
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I'd suggest a decent SQL tutorial would be a good idea.

left join jewelry on id=jewel2

should probably be

left join jewelry on jewel.id = 2

assuming I have worked out what you actually want to do
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to outputting "word" instead of (number) with WHERE clause jewel="diamond"
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10737 seconds with 12 queries