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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 how to use query to retrieve only one tuple?

Author  Topic 

marcusN
Starting Member

6 Posts

Posted - 2004-11-04 : 21:32:48
dear experts

i need to find one query that can only return one unique attirbute froom the table.

something start like this: there one module in the application name "setup TOC BRANCH", certainly the data processing staff will insert the data inside....

each branch is represent by unique "Branch_ID", then of course following by "ADDRESS", "ZIP".....

so the starting point for writing the query would be in this way

select branch.branch_Address (the PK in the Branch table is brnch.id)
from branch
where branch....(???)

in this case, the conditional "where" clause will be very crucial on my fetching data process. let say an example tuple in the branch table would be: [001][ca][lot 500][88300]. 001 is branch id and lot 500 is address

the where condition cannot just state as "where branch.id="001" because the running application is depending on the applcation.id (another table to specify the application)

any solution that can just write the in the conditional where that can function as "if the branch.id is 001, then disply the branch address of (depending on the branch.id)



robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-11-04 : 21:49:42
You'll need to explain this a little better:
quote:
the where condition cannot just state as "where branch.id="001" because the running application is depending on the applcation.id (another table to specify the application)
It sounds like you're trying to join two or more tables together. There appears to be some data in the Branch table that would identify what application it is using. If not, then I don't see any way at all of getting the data you need, certainly not without more information on the tables involved.

It would also help a great deal if you provided your table structures as data definition language (DDL), like so:

CREATE TABLE Branch ( ID int NOT NULL PRIMARY KEY,
branch_Address varchar(50) NOT NULL,
otherColumn varchar(20) NULL)


You can generate this from Enterprise Manager if needed. Right-click the table and choose "Generate Script".

It would also help if you provide some example data, and a sample of the result you're trying to get.
Go to Top of Page

marcusN
Starting Member

6 Posts

Posted - 2004-11-04 : 22:51:24
the re problem if i joining with others table, it will return the result of "return more than one rows"

as the logic, if i want to print report, then the report header must have the address for that branch, then i used it's branch.id to map its address.

if i hard coded it like [001] then its address.......until [100], then it's not flexible. the data setup for branch by fulfilling every detail according to the user....

just like at branch.id [001], then whatever thing they do is just recognize by branch.id, because this is a client-server application, data is reside at server side...

Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-11-05 : 05:29:06
start from basics...
supply ddl, sample input data and sample (matching) expected results.

you'll get to the finish line faster.
Go to Top of Page
   

- Advertisement -