View Single Post

   
  #1 (permalink)  
Old 02-28-2008, 07:38 AM
Ministry
 
Posts: n/a
Default newbie: "complex" query

Hi all,
I've a problem writing a VB 2005 application that interacts with a mysql
database that stores the correspondence with our customers.
I hope you can understand me since I'm italian.

I've got two tables:
the first one is called CORRESPONDENCE and is similar to this:

id subject cathegory
--------------------------------
1 bla bla bla 1
2 bla123 1
3 bla1 bla2 bla3 2
4 123blabla 1
.... ... ...

the second one is called CATHEGORIES:

id description
--------------------
1 italy customers
2 france customers
3 uk customers
.... ...

So as you can se the "cathegory" column of the first tables simply
indicates the cathegory which a letter belongs to (italian customers,
french customers and so on)

Now I want to build a query that simply list all the stored letters,
showing the description of their cathegory, not only its id.

the outpuk should look like this:
1 bla bla bla italy customers
2 bla123 italy customers
3 bla1 bla2 bla3 france customers
4 123blabla italy customers
....

This work should be done with a single query, without using subroutines
or subqueries. I would use something like:
"SELECT id, subject, cathegory FROM correspondence ORDER BY id
AND id, description FORM cathegories WHERE
cathegories.id=correspondence.cathegory"

But of course I dont't know the correct syntax, supposing of course this
could be possibile! :-)

thanks in advance
m.

Reply With Quote