Sorry to post a begginer question here... I am having difficulty with MySQL query here. do I use "join" or "sub-query" for things like this? I'm hoping that someone can show me how to write query for things like this.
I have following tables:
table: special
contains: special_id, special_name
table: keyword_2_special
contains: keyword_id, special_id
table: keyword_2_product
contains: keyword_id, product_id
table: product
contains: product_id and other things
What I would like to do is this. I get the special name from POST action and set the valiable to $special_name. From there, I want to list all the product that has same keyword_id as the special.
With my limited knowledge, I wrote multiple query to get the product_id's, I don't know how I get product_name's from those product_id's since there are multiple products in the result...
I have tried searching the solutions all over, but I guess I'm not searching with the right word...
Any help is greatly appriciated.
2 1620
To me I think the following query (not tested) should do it. Of course there are a hundred ways to accomplish it (with JOINs, for instance). Give it a try: - SELECT
-
special.special.id, special.special_name,
-
keyword_2_special.keyword_id, keyword_2_special.special_id,
-
keyword_2_product.keyword_id, keyword_2_product.product_id,
-
product.product_id, product.other_things
-
FROM
-
special, keyword_2_special, keyword_2_product, product,
-
WHERE
-
special.special.id = keyword_2_special.special_id AND
-
keyword_2_special.keyword_id = keyword_2_product.keyword_id AND
-
keyword_2_product.product_id = product.product_id;
Ronald :cool:
Select * from special s
left outer join keyword_2_special k2s on s.special_id = k2s.special_id
where s.keyword_id = $special_name
i am sure this isn't what you are looking for but i didn't fully understand what your looking for here give me example of the tables like 3 lines of each table and Explain alittle better what fields you want to be joined onto what other fields.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lenz Grimmer |
last post by:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
MySQL 4.0.14, a new version of the popular Open Source/Free Software
Database, has been released. It is now available in source and binary...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest...
|
by: Cern |
last post by:
Is it somebody out there who has made a migration from an Oracle server to an MySQL server??
The scenario is as simply:
I've got a Oracle 8 server with a database with content that I want to...
|
by: jlee |
last post by:
I'm pretty much a newbie on mysql, and I need some help.
I am running mysql Ver 12.22 Distrib 4.0.24, for portbld-freebsd5.4
(i386) on a server hosting an active website.
The site's developer...
|
by: Good Man |
last post by:
Hi there
I've noticed some very weird things happening with my current MySQL setup
on my XP Laptop, a development machine.
For a while, I have been trying to get the MySQL cache to work....
|
by: Juan Antonio Villa |
last post by:
Hello, I'm having a problem replicating a simple database using the binary
log replication, here is the problem:
When the master sends an update to the slave, an example update reads as
follows:...
|
by: Ike |
last post by:
Recently, I began using a different MySQL verver (i.e. different machine as
well as different version#, going from 4.12a to 4.1.9 max).
The following query used to work:
select firstname,...
|
by: Me Alone |
last post by:
Hello:
I am trying to edit some C code I found in "The definitive guide to
using, programming, and administering MySQL" by Paul DuBois. This C
client program connects and then segfaults when...
|
by: Atli |
last post by:
You may be wondering why you would want to put your files “into” the database, rather than just onto the file-system. Well, most of the time, you wouldn’t.
In situations where your PHP application...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |