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.
| Author |
Topic |
|
tieeem
Starting Member
2 Posts |
Posted - 2006-12-06 : 20:09:26
|
| I'm trying to develop a booking system to improve my knowledge of SQL and Java, so far it's going amazingly, far better than I expected. However the book I have on SQL doesn't cover the particular problem I have run into.Basically, I have the fields - ID, Name, DOBI use a SELECT query to get the name field.What I want to know however is, is there any way of determining the ID field from the value supplied by the name. so if the name was "JSmith" could I use this in a query to find out the ID of JSmith.I know I could do "Select ID, Name from customer where ##"but that's not an option due to the way i've programmed the java side.I need to start a new query to get the ID seperatly, Is there anyway of finding the ID from the name?Regards, Tim |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2006-12-06 : 20:25:12
|
| SELECT ID FROM Customer WHERE Name = 'tieeem'That's the way it's done in SQL Server. You can either create a stored proc that returns a value or execute the above statement against your database and extract the name from the resulting recordset.I don't know what you mean by 'but that's not an option due to the way i've programmed the java side.' Perhaps you might want to elaborate.... |
 |
|
|
tieeem
Starting Member
2 Posts |
Posted - 2006-12-06 : 20:41:38
|
| That's got it working thanks.Java Side, As in I couldn't think of a way to doSelect Id, NamePut the result into a String, and then extract the ID from that String and put it into an Integer. |
 |
|
|
|
|
|