PDA

View Full Version : Could I


luigicannavaro
12-09-2008, 07:43 AM
Hi,

Ok. I did with help of codingforums experts several progress in my script.

Again I am trying output that:


<form type="get" action="mytables.asp" >
<input type="text" name="look_for" >
<input type="submit" value="Go!" style="height : 25; width : 30;">
</form>


For example: I put the word "journal" in my input taking the following tables:

I have two tables:

TABLEA

1 Economics
1 is
1 a
2 pathbreaking
2 journal
2 that
2 captures
3 the
3 advantages

TABLEB

1 Economics at About.com makes the dismal science of economics 2
2 Although journal is sometimes used as a synonym for "magazine"
3 Definition of advantages from the Merriam-Webster Online Dictionary


How I generates a 3rd table in this way:

TABLEC

2 pathbreaking
2 journal
2 that
2 captures

In other words: I am looking for "journal" that match with tableA that have in tableB, but I show just the fields of TableA, that have the same ID, listing all single words with same ID.

Best regards

Luigi

Spudhead
12-09-2008, 05:29 PM
That's got to be the most unhelpful thread title of the year. PLEASE try to use something descriptive.

As to your query, I don't think you need the second table at all. You just left join the first table to itself.

SELECT t1.id, t1.word
FROM tableA t1
LEFT JOIN tableA t2 ON t1.id = t2.id
WHERE t2.word = 'journal'

Might be wrong, though.

luigicannavaro
12-10-2008, 10:49 AM
I never thought in join the table to itself. Great idea!

You just left join the first table to itself

It is a script that does headache. I have 3 records in this table, but it shows just the records of id=2. Donīt laugh, please!

Thanks for your code and feedback was very useful

Luigi:thumbsup: