I am attempting to attach a second database to an sqlite3 connection to a database. However when I attempt to retrieve the tables from the connected database sqlite crashes as there is no such table. Even though the PRAGMA database_list sqlite command displays the connected database file, implying that the attachment was successful. Answer db_2_name’s value is a string that
Tag: where-clause
Complex Conditional Query in Where Clause
In my company, each department has their own statuses for purchase orders. I’m trying to load only the pertinent POs for a specific user’s department. I keep getting errors. It seems like it should be correct, though. I initially attempted to use a Case statement, but it appears that SQL can only do a simple return from a case, so
How to Exclude Record Based on Multiple Fields where Records May Share Values
I have two tables of addresses. They are formatted very similarly, to [main] table also has the customer name The shipto table has many addresses for each main customer, and many times the main addresses is also listed as a shipto. I do not want to include that main address in my results but I can’t get it to work
SQL where clause selecting specific data
In Microsoft SQL, I am trying to select a specific result from a table when available. Otherwise, other data should be retrieved. Giving the scenario tableA contains various fruits. I want to collect apples that are red otherwise, any other colors except for red should be retrieved. I am not sure which approach to go with, having a Case Statement
SELECT from Multiple IF conditions in Where Clause
I have a following query In the above query I need to add IF condition that IF a.Type is Accessories then I need certain a.Brands to select from and if a.Type is Clothing then I need to select from certain a.Brands Answer Use a CASE expression, but you should also write a proper join with an ON clause for the
CASE statement in WHERE CALUSE – Missing keyword error
I have list of products which gets renewed on monthly or yearly or both. If the renewal value is ‘M’ then the product is renewed on monthly basis. If the renewal value is ‘Y’ the the product is renewed on yearly basis. So my query is, If I choose method(M/Y) and a particular date(P_date), I want the details of products
Search for a range of characters in SQLite
Assume the table is “t” and field is “f” and of type VARCHAR or TEXT. The SQL queries listed below work with MS Access 97. We are in the process of updating the database to SQLite3 (long overdue!), and these queries return no results. Is this feature to match (or exclude) a range of characters available in SQLite? SELECT *
Using a subquery in a case statement in a where clause
I want to select different results (from a temp table) based on what a certain parameter is set to in the query. I want to exclude certain inventory SKUs if a particular warehouse is selected. I am getting this error, unfortunately. Msg 512, Level 16, State 1, Line 310 Subquery returned more than 1 value. This is not permitted when
SQL return rows on or after an specific date
I am trying to export a list of member details that have an expiry date after 2019 so I am just after I thought I could simply use the date in a WHERE clause However, it still returns the other entries and not sure why Answer Assuming that you are using SQL Server: dbfiddle
Use one of two dates in where clause
I need to delete all records in a table where the CreatedDate or ModifiedDate is greater than x. The logic is as follows: If ModifiedDate is not null then use this value Otherwise use the CreatedDate value Not applying the if/else statement correctly. Answer Use this where clause: