in Education by
I have an integer field person_id with the default value of NULL. I am using a stored procedure and pulling people names and address. if a user does not pass a value all records are pulled both, null and not nulls. How do I do it. May be Case statement or otherwise? my_procedure( <--- this is pseudo code @person_id int null begin select name, address from PERSON WHERE person_id like case NULL then NULL else '%' end Null requires -> IS NULL number requires = 123 EDIT I need a condition too, if nothing is passed, all values are pulled. If something is passed, that value is searched JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
WHERE (@personID is NULL OR personid IS NULL OR personid = @personid) Just put both your cases in a parenthetical WHERE clause. EDIT Added another OR clause to cover what I THINK you are asking for.

Related questions

0 votes
    I would like to take a list of names (e.g. john, mary, paul) and create a SQLite "select" ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    I want to query something with SQL's like query: SELECT * FROM users WHERE name LIKE '%m%' How to do I ... like in the documentation. Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 00: ... How can I get that? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I'm using this formula to calculate the distance between entries in my (My)SQL database which have latitude ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I have two tables containing Tasks and Notes, and want to retrieve a list of tasks with the number ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 12, 2022 in Education by JackTerrance
0 votes
    I have multiple set of data to insert at once, say 4 rows. My table has three columns: Person, Id and ... a single SQL statement? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I have multiple set of data to insert at once, say 4 rows. My table has three columns: Person, Id and ... a single SQL statement? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I have an access table that has in one column a list of groups and then another column that has a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    I have an access table that has in one column a list of groups and then another column that has a ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    SELECT id, amount FROM report I need amount to be amount if report.type='P' and -amount if report.type='N' ... this to the above query? Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    It's easy to find duplicates with one field: SELECT name, COUNT(email) FROM users GROUP BY email HAVING COUNT( ... to find them first. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I am trying to INSERT INTO a table using the input from another table. Although this is entirely feasible ... the underlying database? Select the correct answer from above options...
asked Jan 26, 2022 in Education by JackTerrance
0 votes
    I have an graphql/apollo-server/graphql-yoga endpoint. This endpoint exposes data returned from a database ( ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have an XML file which is structured as follows: place1 location1 place2 location2 place3 location3 These ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I have seen SQL that uses both != and for not equal. What is the preferred syntax and why? I like !=, ... reminds me of Visual Basic. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
...