• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 239
  • Last Modified:

SQL synthax

Hello EE,

I am not sure how to do this.. :

lets say in the table we have :

ID              LineNumber             Amount

1                      1                           0
1                      2                           0
1                      3                          100
2                      1                           0
2                      2                           50


if the user in his Menu click Open...   and choose to open ID 1
I would like the query to show all the ID (even ID 2)  but (and here is my problem) because he chose ID 1 I want to show all row of ID 1 but because he didnt chose ID 2 I need to show only rows of ID 2 that are amount at 0..

so result would be like this:

1    1   0
1    2   0
1    3   100
2    1   0


(not the lineNo 2 of ID 2 because amount is > 0 )
0
PhilippeRenaud
Asked:
PhilippeRenaud
  • 3
  • 3
1 Solution
 
radcaesarCommented:
Sorry I didn't get you exact requirement. Exaplin it clearly
0
 
PhilippeRenaudAuthor Commented:
my table:

ID              LineNumber             Amount

1                      1                           0
1                      2                           0
1                      3                          100
2                      1                           0
2                      2                           50

if user choose ID 1

query result :   All rows of ID1  + rows of all other ID's where amount = 0

if user choose ID 2
query result:  all rows id2 + rows of all other id's where amount = 0
0
 
radcaesarCommented:
Try this

select * from table1  
where (Id=1)
or (ID <>1 and Amount =0)
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
PhilippeRenaudAuthor Commented:
do you think its possible without sending parameter

in your code your hardcode 1  wich i understand you want me to pass a parameter
0
 
PhilippeRenaudAuthor Commented:
no i believe its not possible.
its fine thanks
0
 
radcaesarCommented:
Yes you need to pass parameter.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now