Select and Display Products Not Sold
SELECT DISTINCT i.description, p.invID FROM Inventory i FULL OUTER JOIN Purchasing p ON I.iD = p.invID --WHERE i.invID
Socks 1 Ties NULL Underwear NULL
With where unblock this T-SQL should show Ties, Underwear but shows nothing.
Where am I going wrong?
See also questions close to this topic
fixing the sorting after deleting a record
- I have two tables called as Sequence and the Newsfeed
The newsfeed PK ID is the key which also exists in the sequence table and sequence is stored in newsfeed table,
even the sequence table has the sorting order too but that is not used.
now what i am trying is:
select * from newsfeed where id in (select fk from sequence where pkid = 1000)
- if the internal sub query has some records it will give me a some values maybe
10records or sometime
1and if it does not have any record it will return me nothing, now if it returns me nothing, i will do another query which is like this
select * from newsfeed where id = 1000and it will return me the value
then based upon that am getting the sortorder of the id from the newsfeed table.
and then it gives me the record of that table with sortorder
here comes the tricky part:
sortorder: ID 25 5252 26 5255
i am deleting the
5252record and that
25so i am deleting
25and then before
25its 24 and after
so what i want is the sorting f the records which are after the deleted records:
so it will be like this;
sortorder: ID 25 5252 - because this has been deleted 25 5255 and so on
so the sequence will be have to fixed.
i showed an example of 1 record but if there are more records then that needs to be fixed too,
Limit with Temp tables in SQL
Is there any limit for number of temp tables to create in a Stored Procedure? One of my functionality is so huge with so many hanging modules. The best way I found was to create temp tables for the hanging modules and pull data out from those tables.Right now, there are 22 temp tables in that 1 Stored procedure of 2500 lines. Is there any potential limit or Performance threat related to count of Temp tables?
How to Retrieve png image from varbinary(max) SQL Server in PHP
I'm stuck in converting varbinary(MAX) from SQL Server to png image in php. I've been following tutorial like this:
<!DOCTYPE html> <html> <head> <title>base 64</title> </head> <body> <?php $image_data = "0x89504E470D0A1A0A0000000D4....."; ?> <img src="data:image/png;base64,<?php echo base64_encode($image_data);?>" /> </body> </html>
But it's not working. Is there any difference data blob in mySql and SQL Server?
SQL Server Trigger to Replace "false" With null
I have a table with 2 numeric columns and 3 varchar columns in a MS SQL Server 2017 DB. I want a trigger to check each inserted/updated row and when any of the varchar columns have the text "false" replace it with null.
There is no primary key column and every column is null-able, so I won't be able to join with the "inserted" pseudo table
I am more familiar with Oracle where the logic for this could be something like:
BEFORE INSERT OR UPDATE ON table1 FOR EACH ROW BEGIN IF new.TEXT_COLUMN1 = 'false' THEN new.TEXT_COLUMN1 := null; END IF; IF new.TEXT_COLUMN1 = 'false' THEN new.TEXT_COLUMN1 := null; END IF; IF new.TEXT_COLUMN1 = 'false' THEN new.TEXT_COLUMN1 := null; END IF; END;
Getting different record count from same query
What would be the cause of getting different record count for each occurrence from same query and same source?
the date is "Thu May 31 2018 21:00:00 GMT-0700 (Pacific Daylight Time)"
and when run through
the date is "Fri, 01 Jun 2018 04:00:00 GMT".
Essentially how do I make my value on the client be what it is in the database?