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
Old 11-15-2010, 01:02 AM SQL - Distinct
Banned

Posts: 17
Name: new york
Trades: 0
Hello everyone,
Here I am not a beast in SQL and I want to make a selection a bit special. Only I do not know how.

I have a table that looks like this:

id | en_city | fr_city
---------------------------------


- It is possible that the two fields in the same row are filled.
- One of two fields is always (at least) completed.


I want to select all the fields separately to create a list box.
Only I can not do too much.
Here is my current query:
Code:
<? Php
$ Sql = "SELECT DISTINCT en_city, recruitment fr_city FROM WHERE country = '".$ Country."'"
?>
It sends me a duplicate, in case there is a field and a field en_city fr_city identical.
The problem is that I do not know how to contact the SQL command for the two fields at the same time?


Does anyone know a specific syntax or command to do what I want?

In advance thank you.
edson1314 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-15-2010, 05:59 PM Re: SQL - Distinct
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
and "recruitment" & "country" come from where?
__________________
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!
 
Old 11-15-2010, 09:55 PM Re: SQL - Distinct
Banned

Posts: 17
Name: new york
Trades: 0
are they important?
edson1314 is offline
Reply With Quote
View Public Profile
 
Old 11-16-2010, 12:07 AM Re: SQL - Distinct
Average Talker

Posts: 25
Name: Stephen
Location: Arizona
Trades: 0
build two query statements, one for each city column, and use union to bring back unique results.

SELECT en_city, ...
UNION
SELECT fr_city, ...

remember though, the entire row must be unique to avoid duplicates
__________________

Please login or register to view this content. Registration is FREE
and
Please login or register to view this content. Registration is FREE
GetGamesHere is offline
Reply With Quote
View Public Profile Visit GetGamesHere's homepage!
 
Old 11-17-2010, 09:36 AM Re: SQL - Distinct
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by chrishirst View Post
and "recruitment" & "country" come from where?
If you include them in a query they have to be in the table.
__________________
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 SQL - Distinct
 

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.15233 seconds with 12 queries