Null values in My SQL query

Ruban J

My Query is

SELECT i.status,i.amount_total, i.id,sc.category as category,us.fname as name,us.company as company,
(SELECT transaction_id FROM invoice_payments WHERE invoice_payments.invoice_id = i.id) as transaction_id ,
(SELECT created  FROM invoice_payments WHERE invoice_payments.invoice_id = i.id and invoice_payments.created BETWEEN '2015-01-01' and '2016-01-01') as created 
FROM invoices i
inner JOIN 
users as us ON us.id = i.client_id 
inner JOIN subscriptioncategory as sc ON sc.user_id = us.id

and my result is

enter image description here

in the Created column, i should not get the null values. are there any simple query to fix it.

Jens

Simply join all tables with inner join:

SELECT i.status,i.amount_total, i.id,sc.category as category,us.fname as name,us.company as company,
ip.transaction_id,
ip1.created 
FROM invoices i
inner JOIN 
users as us ON us.id = i.client_id 
inner JOIN subscriptioncategory as sc ON sc.user_id = us.id
join invoice_payments ip on ip.invoice_id = i.id 
join invoice_payments ip1 WHERE ip1.invoice_id = i.id and ip1.created BETWEEN '2015-01-01' and '2016-01-01'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

SQL query with null values

SQL Query to not display null values

Query not returning NULL values - SQL

SQL Query not returning Null values

My query is still returning rows with null values

Why is not null statement not working in my sql query?

STR_TO_DATE in MY SQL Query is Null

Find null values returned by SQL query

c# create a sql query with null values

Handling NULL values in an SQL Query that uses SUM

sql query xml values returning NULL

Replacing null values in dynamic pivot sql query

SQL query group by with null values is returning duplicates

Sql query that not return null values in result

Not able to allow null values in my sql script

Why are my sql foreign key values == null?

Entries in my SQL Query doubles the result values

SQL query to fetch employees with null and not null commission values of a particular department

VBA Code to Paste SQL Query in Excel with NULL values pasted as "NULL"

Single SQL query to tackle NULL and non-NULL values

Dynamic SQL Query to ignore null values based on null value in cell

SQL XML Query/Exist: Looking for null/not null values

SQL query comparing decimal values not matching and returns NULL values

Return NULL as Zero from my SQL Pivot query

Why my dynamic query returns NUL instead of NULL in SQL server?

SQL Query is not returning NULL values despite using IFNULL (MySQL)

SQL query should not return rows that contain null values in pivot table

SQL Server Query: Using JOIN to include NULL values

SQL-query order by multiple columns having null values