Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql read all Foreign keys

Author  Topic 

Musti4300
Starting Member

3 Posts

Posted - 2013-05-14 : 16:05:29
BorderTable
+-----------------------+
| border |
+-----------------------+
| braet_image1 |
| braet_image2 |
| braet_iamge3 |
+-----------------------+


History Table
+-----------------------+---------------------------------+
| id | startX |startY| endX| endY | winOrLose | BorderTable_border |
+-----------------------+---------------------------------+
| 1 | 2 | 2 | 3 | 3 | Nej | braet_image1 |
| 1 | 4 | 4 | 5 | 5 | Ja | braet_image2 |
| 1 | 2 | 3 | 6 | 6 | Ja | braet_image3 |
+-----------------------+---------------------------------+


The quesation is:

I want to select one of the borderTable, and get all history related to selected table. how can i do that. Can you please make a query. Im new in sql, i tried in few hours and now 6 hour gone, and still same place. Please help.

Bedt regards

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-14 : 16:56:15
What would be the output you are looking for for the sample data you posted?
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2013-05-14 : 16:57:57
Help us to help you. I'm not clear on what you want as the output. Can you give us an example using the data you have supplied?

=================================================
I am not one of those who in expressing opinions confine themselves to facts. (Mark Twain)
Go to Top of Page

Musti4300
Starting Member

3 Posts

Posted - 2013-05-14 : 16:58:35
I try with this but never work


SELECT
startX,
startY,
endX,
endY
FROM
History
WHERE
border = braet_image1

I want to select one of the border, and get the related history to selected one. If i choose braet_image1 then it should return this : 1 | 2 | 2 | 3 | 3 |
But how.
Go to Top of Page

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2013-05-14 : 16:58:50
I am assuming that the image is a varchar or char datatype:[CODE]SELECT
ID,
startX,
startY,
endX,
endY
FROM
History
WHERE
border = 'braet_image1'[/CODE]


=================================================
I am not one of those who in expressing opinions confine themselves to facts. (Mark Twain)
Go to Top of Page

Musti4300
Starting Member

3 Posts

Posted - 2013-05-14 : 18:03:46
Bustaz Kool Thanks man, it works. I can get all history from selected table. Thank you very much, may god bless you.
Have a nice day.
Go to Top of Page
   

- Advertisement -