-
Table syntax
My partner asks this question:
MS SQL only, please and thank you in advance. Want all you experts to know that even when we can't successfully complete what we need to do and have to start over, YOUR information makes the redo successful and easier.
Question 1: I have a table with several columns of data. In my webform, I need to call the data from Table1.ColumnA and have the data in Table1.ColumnB display. Can't seems to get the syntax right. Help would be much appreciated!
-
Select Table1.ColumnB from Table1 where Table1.ColumnA ='mydata'
-
table syntax
Try to explain in detail what we are doing. We have it in Query Analyzer but have not yet figured out how to transfer it to the webform
What we are doing: I have an MS SQL table with an animal's name(Col. A), registration number (Col. B), sire's registration number (Col. C) and dam's registration number (Col. D). I want to input the animal's name or number and show it's parent's names, rather than the numbers. The parent's are, of course, also listed as animal's by name and number in Col. A.
So, as I get to the parents, I have only columns C and D to bind to the
cell, but need the corresponding information from Column A to be what is
actually displayed. I am having trouble visualizing the logic of the query I
need.
QUESTION: Suggestions?
QUESTION 2: In general, is this how to use one column to locate a record but display the results from another column?
-
No answers, no solutions to our dilemna?
-
Join the table on itself. This will find the parents if the child dog is known:
Select Sire.ColA, Sire.ColB, Dam.ColA, Dam.ColB
From Table1 As Dog1
Left Join Table1 As Sire On Dog1.ColC = Sire.ColB
Left Join Table1 As Dam On Dog1.ColD = Dam.ColB
Where Dog1.ColB = ChildRegNumber
To find the child if the parents are known:
Select ColA, ColB
From Table1
Where ColC = SireRegNumber
And ColD = DamRegNumber
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|