|
Hi,
I have a table like this:
Param Cat Payee Amt1 Amt2
AS x1 y1 23 34
AS x1 y2 43 53
BJ x1 y1 53 33
I want to select row 1 and row 3.
For just row1, I write,
“SELECT * FROM Tab1 WHERE Param=’AS’ AND Cat=’x1’ AND Payee=’y1’”
But how do write the sql if I want both the 1st row and the 3rd row. They both differ in only the Param name.
Please can you tell me.
Thanks,
Tara
Fortitudine Vincimus!
|
|
|
|
|
|
try
SELECT * from Table1 where Payee = 'y1'
or
SELECT Top 2 * from Table1 ORDER BY Amt2
if depends on what you want to filter by.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
I have to calculate the difference between the amounts in the 1st row and that in the 3rd row.
I understand what a primary key is, but my database does not require it, or so I think!!
Nevermind. I did it differently. Got the 1st row, collected the amounts in an array, then got the 2nd row and did the calculation.
If there is a better approach to doing the calculation, I would be glad to know.
Thanks,
Tara
Fortitudine Vincimus!
|
|
|
|
|
TheinstruTara wrote: I have to calculate the difference between the amounts in the 1st row and that in the 3rd row.
First a wee bit about databases. They deal with sets of information, using set based queries. In a set there is no concept of order, although many database systems can impose a concept of order by using the ORDER BY clause in SQL. So, as far as the datbase system is concerned there is no 1st and 3rd row.
TheinstruTara wrote: I understand what a primary key is, but my database does not require it, or so I think!!
If you want to refer to a specific row you need a primary key. If you understand what a primary key is you should know that is will always uniquely refer to a row.
You mention a calculation, but you never mentioned this before. If you are looking for a better way to do a calculation then you need to let us know what the calculation is in order for us to help you with that.
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
-- modified at 15:30 Wednesday 5th July, 2006
|
|
|
|
|
Thankyou so much for your help.
I am coding a program in vc++ and I use MS Access as the database. We need to know a little bit to sql to interact with the database. I just mentioned 1st row and 3 row as examples.
In my program I do not know which row it actually is. Therefore, even if there is a primary key assosiated with a row, its of now use to my program.
I was trying something like this:
SELECT * FROM Tab1 WHERE param='AS' AND param='BJ' AND cat='x1' AND payee='y1'
But the sql was not accepted.
Fortitudine Vincimus!
|
|
|
|
|
TheinstruTara wrote: WHERE param='AS' AND param='BJ'
That says that the column called param must be equal to 'AS' and 'BJ' at the same time. This is, naturally, impossible.
I'm guessing what you actually wanted to do was:
SELECT * FROM Tab1 WHERE param IN('AS', 'BJ') AND cat='x1' AND payee='y1'
If MS access cannot handle the IN() operator then it is logically equivalent to
(param = 'AS' OR param = 'BJ') (note the brackets are also important)
TheinstruTara wrote: In my program I do not know which row it actually is
You must know something about the rows you want, you are putting stuff in the WHERE clause - Unfortunately it means nothing to me, so it is difficult for me to make meaningful suggestions.
And, you still haven't mentioned anything about the calculation you are doing.
Scottish Developers events:
* .NET debugging, tracing and instrumentation by Duncan Edwards Jones and Code Coverage in .NET by Craig Murphy
* Developer Day Scotland: are you interested in speaking or attending?
My: Website | Blog
|
|
|
|
|
Dose'nt matter. It's OK. Thank you.
Fortitudine Vincimus!
|
|
|
|
|
I am Having DropDownList,GridView1 and GridView2 in my page.
If i select one value in the DropDownList that related data has to display in the GridView.
Please help me out. Very Urgent.
Thanks
Kalpana
|
|
|
|
|
This should not be posted in the SQL forum !
basically you need a SelectedItemChange event on your DropDownList that runs a SQL query and then binds the data to to your gridview.
Look where you want to go not where you don't want to crash.
Bikers Bible
|
|
|
|
|
Frank Kerrigan wrote: This should not be posted in the SQL forum !
This could arguably be deemed an ADO.NET question as well as a ASP.NET question. Either forum is correct, imo.
Jerry
“Profanity is the attempt of a lazy and feeble mind to express itself forcefully”
|
|
|
|
|
|
I'm being kind and looking at it as implied.
“Profanity is the attempt of a lazy and feeble mind to express itself forcefully”
|
|
|
|
|
1. What does this have to do with SQL (the subject of this forum)
2. The people here volunteer their abilities in their spare time, for free, for the benefit of others. Saying your problem is "Very Urgent" is not going to get you a faster response. I would suggest that it does, in fact, turn off some people because they would rather help someone who appears to appreciate the scenario in which the questions are being asked. i.e. a community forum.
If you want urgent help with your problem then I would suggest you call Microsoft Support who will help for a small fee.
|
|
|
|
|
This could arguably be deemed an ADO.NET question as well as an ASP.NET question. Either forum is correct, imo.
Jerry
“Profanity is the attempt of a lazy and feeble mind to express itself forcefully”
|
|
|
|
|
When I update data,I hope the datetime change together.so,I use the Now() function,but throw the Excetption.look at following:
@ID
@name,
@sex,
@age,
"Update mytable set name=@name,sex=@sex,age=@age,DateTime=now() where ID=@ID"
so,how to modify?who can help me?
thank you!
KSCsoft
|
|
|
|
|
you can always can have the value of "date" field filled with the current date/time by setting the field's Default value to =Now() in Access table design mode.
What is the exception you get?
|
|
|
|
|
you are right!but it is insert,not the update.
KSCsoft
|
|
|
|
|
KSCsoft wrote: @ID@name,@sex,@age
MSAccess doesn't use the @ symbol for variable naming. Your problem isn't the 'now()' function.
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I use @ symbol for variable naming in the asp.net.
I just wanna know When I update record,the datetime field's value is the current time!
KSCsoft
|
|
|
|
|
DateTime is a reserved word in MSAccess, and you have chosen it as one of your field names. Try using brackets around it: [DateTime]
--EricDV Sig---------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
I wanted to transfer the data of one database to blank database in SQL With Windows Application
divya
-- modified at 6:38 Wednesday 5th July, 2006
|
|
|
|
|
I would recomend using management tools (that comes with your database) to perform a data migration tasks.
Best regards,
-----------
Igor Sukhovhttp://sukhov.net
|
|
|
|
|
divyaswati wrote: Please help me it's urgent
This is a useless subject line. It tells those who can potentially help nothing about your problem. Your subject line should describe your problem in a few words. For example: "Transferring data between databases" would be a much better subject line.
There are no guarantees about the speed we can help with your problem. We are all volunteers and help when we can. So, describing your problem as "urgent" is unlikely to have any impact on the speed with which you receive an answer.
|
|
|
|
|
Hi,
What event should I use to trigger an update of a dataset to the originating DB, in order to take max advantage of dataset scalability without losing data?
I'm building an ASP .NET website driven by an SSE database. Hopefully there will be several thousand users. When a user logs on, the codebehind queries the DB and retrieves up to several dozen records belonging to that user. The user can add, delete, and modify records on several webforms. I'm using a dataset and SqlDataAdapter to get the records at login and caching them in the Session object.
Right now I'm calling SqlDataAdapter.Update(dataset) every time the user submits a webform with a new record. That works, but it doesn't seem very efficient. But I can't figure out how else to do it without potentially losing records. What if the user enters a record, and then closes the browser window? What if he times out or goes to another website before my Update method runs?
How do I take better advantage of datasets and data adapters? Is there a way to detect the end of a Session and set up an event handler to run an update then? Or maybe cache to the Application and run an update on time intervals?
I apologize if this question is elementary. I'm early in the learning process for C# / ASP .NET / ADO.
TIA
-- modified at 0:15 Wednesday 5th July, 2006
|
|
|
|