1

I've a problem with my program in c# and i hope, you can help me.

My database looks like this:

http://www11.pic-upload.de/08.09.15/czq5yxrrcf24.png

and I want to save the last value of "MaxZyklus" in a variable in c#.

My query to the server is okay, when I write it like this:

select Kabel.maxZyklus 
from Kabel 
where Kabel.kabelTyp = 'PM-K031' 
  and ID = 20; 

select max(ID) from Kabel

but I don't know, how I can do it in one query, and save it in C# as a variable

Hope you can help me.

1
  • This seems more related to basic SQL than to c#. Commented Sep 8, 2015 at 8:42

2 Answers 2

1
SELECT YourField FROM YourTable 
WHERE YourKey =(SELECT MAX(YourKey) FROM YourTable )
Sign up to request clarification or add additional context in comments.

Comments

0

I found the correct query at

select Kabel.max Zyklus form Kabel where ID = (select max(ID) from Kabel where Kabel.kabelTyp = 'PM-K031');

now saving in a vatiable :) suggestions?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.