When using a UUID data type as the primary key of a table, and asking H2 to generate each UUID value by default upon INSERT of a new record, how does one access the value of the newly generated UUID value? I am using plain JDBC 4.x in a Java app, if that helps with a solution. I know SCOPE_IDENTITY
Tag: sql
Proper way to count how many times an item from 2 lists of items are ordered together
I am currently self-learning SQL so for most of you this would probably seem like a simple question (if I expressed it correctly). I have a table ‘orders’ that look like this: What I want to do is count the times that any item from 2 lists of items (as in IN (itmsid1, itmsid2) coexists for all Ordmids. For example,
Join on TOP 1 from subquery while referencing outer tables
I am starting with this query, which works fine: SELECT C.ContactSys , … a bunch of other rows… FROM Users U INNER JOIN Contacts C ON U.ContactSys = C.ContactSys LEFT JOIN …
T-SQL Union (distinct, not all) and Order by with priority
Assume I have a Tag table (Id int and Name nvarchar(100)) with 3 values: 1 Software 2 Hardware 3 Warehouse Now I want to query with keyword, and prioritize the ones that starts with the keyword over …
Remove matching values by comparing two database tables Codeigniter/Mysql
In my codeigniter model I have this function : public function getUserNo() { $query = $this->db->query(“select userno from Users where active=1”); return $query->result_array(); } …
How to get details for a customer that is both a seller and a buyer
I have a database which contains customers that are both buyers and sellers. the customers can buy and sell houses. I need to get details for the customers separately and still have a connection …
Left join not returning null records
I’am dealing with a pretty basic SQL query, but I cannot understand why the non matching records are not represented with the null values in right table. I have table A and table B with a composite …
Distinct sql based on condition More than two columns
Below is the table structure. Column one contains strings which might be present in more than one row. I want to write a query in such a way column1 value is only repeated once such that row where …
Using inner join instead of subquery
I wrote a query using a subquery, but I wonder if there is any way to write it using only inner join (or other joins) since it’s more efficient. /*2. List the name of the sales rep who serves the …
Excel VBA with SQL : No row returned when Where clause specified
Here below an excerpt of my codes. This is the SQL command : Where the database located : The variable containing the string connection to the DB : The wrkSheet for the result : This command Adding QueryTable as a ListObject returns ZERO occurrence because of Where Clause whereas the SQL is OK. If the Where Clause is removed, it