Skip to content
Advertisement

Tag: sql

Show data from table even if there is no data

I have 3 tables: Data in Compania table: Data in Periodo table: Data in VAC_PERIODOCIA table: I want to show all the companies (COMPANIA) and the value in (vac_aplica column) searching by Periodo, whether or not they are registered. I tried this: Result: What I want is this: Answer First of all, the question is a mess: tables and columns

cartesian product on two tables

I’m trying to create a result set of table names and column names. In table A I have the list of table names and in Table B I have the list of column names. Each table should have the full list of columns. So: Table A table_name Table1 Table2 Table B column_name Column1 Column2 Column3 The result I want is:

How to create query more than two table in SQL?

I found difficulties answering Q2. Q1) Total order value (amount) of the orders placed in the period Jan 2022, from the area Jakarta Q2) How many orders raised for Product = “OPPO A31” in the category = “Mobile Phones” in Jan 2022? And, by how many customers in Jan 2022? Answer Here are a pair of queries for you to

SQLSTATE[22007]: Invalid datetime forma

I try to save some data that it brings me from my view, which is a table, but I don’t know why it throws me that error with the insert. result of insert this is my view: table of view this is my controller: Answer id_tipo_venta seems to be an empty string which is apparently not valid. You can try

Set new field priority in SELECT SQL

I have a table of bills with the following structure: What I need is to select all data from table and set additional field “Priority” based on a sum of bill. First 2 rows get priority 1, next 2 rows get priority 2, others get 0: In addition table contains data about bills from various days (field payment_date) and this

NULL MAX(col) value even though DB has a valid record

So I am trying to extract the maximum invoiceNo for current year and this is how I implemented it with PDO: However, $response keeps getting assigned to the else clause : . This is how my DB looks like: Hence I was expecting the $response to be 2022-2. I think there is something wrong with my SQL query and I

Advertisement