Connecting Tech Pros Worldwide Forums | Help | Site Map

mysql query

Newbie
 
Join Date: Oct 2008
Posts: 2
#1: Oct 25 '08
I have a language learning site. And there I have a vocabulary exercise. In my database I have a table called words. It has three fields. id, english and turkish. In that exercise I have to select from both columns the single words for example :

id english turkish
1 book kitap
1 student ogrenci
1 school okul
2 book kitap
2 boy erkek
2 propose onermek
3 suggest onermek
3 book ayırmak


Then, the output that I want is

book kitap
student ogrenci
school okul
boy erkek
propose onermek

So that I can match these in my exercise.How can I write it in mysql?
Thanks for help.
--------------------------------------------------------------------------------

mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 719
#2: Oct 25 '08

re: mysql query


Can you explain on which rule you want to include or exclude the words? A simple solution would be the use of GROUP BY e.g.

Expand|Select|Wrap|Line Numbers
  1. SELECT english, turkish FROM words
  2. GROUP BY english
Newbie
 
Join Date: Oct 2008
Posts: 2
#3: Oct 25 '08

re: mysql query


No this is not . Because from turkish there are two "onermek" field. However I have to get one of them. A sample solution is the following but mysql does not support intersect. How can I write it in mysql? Thanks.

select english,max(turkish) from st
group by english

intersect

select max(english),turkish from st
group by turkish
Reply