SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Sql read all Foreign keys
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Musti4300
Starting Member

Denmark
3 Posts

Posted - 05/14/2013 :  16:05:29  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3575 Posts

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

Bustaz Kool
Flowing Fount of Yak Knowledge

USA
1673 Posts

Posted - 05/14/2013 :  16:57:57  Show Profile  Reply with Quote
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

Denmark
3 Posts

Posted - 05/14/2013 :  16:58:35  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
1673 Posts

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



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

Edited by - Bustaz Kool on 05/14/2013 17:03:24
Go to Top of Page

Musti4300
Starting Member

Denmark
3 Posts

Posted - 05/14/2013 :  18:03:46  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000