Skip to content

Transpose each row in SQL SELECT

The following SQL SELECT concat(‘CSE_’, course_code), concat(‘CS_’, course_code) FROM classes this returns some like this: CSE_210 CS_210 CSE_570 CS_570 CSE_480 CS_480 Instead I need …

Trigger with insert and calculations

I Have two tables, TableA which has a primary key (A_ID) and a salary column. Table B has a primary key (B_ID) and a paymentAmount column. I need to create a trigger so that once TableB B_ID is …

How to get the most recent data from a table?

Here is the table that I have The question that I have for my query is “Using the most recent month of data available, what is the range of estimated home values across the nation?” Since my table is small, I know the recent date is 2020-06. So I wrote this code: And the result that I get is: Anot…

Set default value for all columns of a table

I have multiple tables with a lot of columns. Some columns contain Null values. Now, i want to set them to a default value (empty string or 0). I found two two pieces of SQL that probably cover what i need but i can’t put them together. I can use the above code to get all columns and their data

Query to get IDs related to certain foreign keys but not others

I have two sites with separate WordPress instances. One is in the process of getting WooCommerce, the other has existing users with set groups to access courses. I the future access to the courses is supposed to be sold via the shop. The answer I’m looking for has nothing to do with WordPress per se but…