473,320 Members | 1,950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

an SQL join question which I can not figure out


Suppose I have three tables like this:
table weblogEntries{
id
headline
mainContent
dateCreated
}

table keywords {
id
keyword
}

table whatKeywordsApplyToWhichEntries {
id
entryId
keywordId
}
Any time a record in whatPropertiesApplyToWhichEntries has an entryId
and a keywordId, then that entry has had that keyword assigned to it.

If I wanted to get an entry, along with all keywords that have been
applied to it, how would I do so? If I don't know how many keywords
have been applied to the weblog entry, what's the syntax of the join?

Jul 17 '05 #1
1 1405
On 9 Jun 2005 13:45:19 -0700, lk******@geocities.com wrote:
Suppose I have three tables like this:

table weblogEntries{

table keywords {

table whatKeywordsApplyToWhichEntries {

Any time a record in whatPropertiesApplyToWhichEntries has an entryId
and a keywordId, then that entry has had that keyword assigned to it.

If I wanted to get an entry,
So that's one row.
along with all keywords that have been applied to it,
That's potentially multiple rows.

So either

* two queries (one for the entry, another for the keywords), or

* end up with repeats in the data returned for the entries fields, from a join
with a the entry-keyword mapping table, one row per keyword.
if I don't know how many keywords
have been applied to the weblog entry, what's the syntax of the join?


If you were thinking you can get a variable number of columns out of this, one
per keyword in a single row then forget that idea; that's not how SQL works.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Surly | last post by:
Both the Microsoft and the Oracle ODBC driver will take an outer join with the "{oj....}" ODBC syntax and Put the (+) on one column as determined by order of the columns in the "Left Outer Join"...
4
by: Thomas Brown | last post by:
I'm having a bit of a SQL problem and I can't figure it out. I have a working solution, but it could be better. I've got two tables, tblInspections and tblViolations. Each inspection...
2
by: Lee | last post by:
I have two identical schema tables (one in a production library and another in a development library) and I need to be able to easily compare the data in them for errors and omissions. With...
1
by: Pejo | last post by:
Table Users FName(text), LName(text), UserID(number) Table Correspondence. Date(datetime), msg_From(number), msg_To(number) Table Users Data John, Quincy, 1 Jane, Doe, 2
6
by: davegb | last post by:
I'm trying to create a self-join table to show the relationship between employee and supervisor. In another thread, I was advised to create a SupervisorID in the employee table, a separate...
14
by: Jim Andersen | last post by:
I have a problem with this standard employee-supervisor scenario For pictures: http://www.databasedev.co.uk/self-join_query.html I want to show all employees "belonging" to a specific...
7
by: Shanimal | last post by:
I would like to know how to join 2 queries so that the results of these 2 queries show up in the same query: SELECT b.bios_serial_number FROM bios b: SELECT s.system_name FROM system s; ...
52
by: MP | last post by:
Hi trying to begin to learn database using vb6, ado/adox, mdb format, sql (not using access...just mdb format via ado) i need to group the values of multiple fields - get their possible...
0
by: yeahuh | last post by:
Quick and dirty version. Godaddy server using MySQL 4.0.24 I’m trying a left join to obtain id’s in table A(cars) that are NOT in car_id in table B(newspaper): *This is a cut down version...
23
by: Summercool | last post by:
i think in Ruby, if you have an array (or list) of integers foo = you can use foo.join(",") to join them into a string "1,2,3" in Python... is the method to use ",".join() ? but then it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
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)...
1
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....
0
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
0
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.