SQL Tricks | How to find value in multiple columns ?
HTML-код
- Опубликовано: 19 дек 2022
- In this tutorial, we write a SQL Query to find a value in multiple columns.
STRING_AGG tutorial
• SQL Query - Convert da...
How to concatenate rows into column for older versions of SQL Server?
• SQL Query | How to con...
Dynamic SQL tutorial
• SQL | Create and Execu...
Practice dataset and SQL code available here -
know-star.blogspot.com/2022/1...
How to install SQL Server for practice?
• How to install SQL Ser...
Check out the complete list of SQL Query Interview Questions -
• SQL Query Interview Qu...
Best Data Science / Analytics / SQL courses
Learn SQL Basics for Data Science Specialization
imp.i384100.net/qnXYk5
Beginners to Python Programming
skillshare.eqcm.net/GjMakm
Data Science and Business Analytics with Python
skillshare.eqcm.net/JrM1Aq
IBM Data Science Professional Certificate
imp.i384100.net/LPQvg3
Data Science Fundamentals with Python and SQL Specialization
imp.i384100.net/mgVYre
Python for Everybody Specialization
imp.i384100.net/DVz7Aj
Google Data Analytics Professional Certificate
imp.i384100.net/OR37oQ
Coursera Plus - Data Science Career Skills
imp.i384100.net/c/3299742/132...
Please do not forget to like, subscribe and share.
For enrolling and enquiries, please contact us at
Website - knowstar.org/
Instagram - / learn.knowstar
Facebook - / knowstartrainings
Linkedin - www.linkedin.com/company/know...
Email - learn@knowstar.org
Oh my goodness, its very very helpful... Many thanks to you.
Thank you
As per your example from Tbl1, If I want to find demo in col1, col2, col2, col4, col5 ? Pls reply
Hi ,
I want to find max date for each tables present in each schema how to write it dynamically
Thanks!
Thank you so much for your support 🙏
I learnt lot from this channel, good explanation ma'am
Glad to hear that
Thanks for sharing
Thank you
Great video ma'am
One question
where 'cancelled' in (col1,col2) is available just in SQL server or is it universal?
Thank you. Might not work in all databases.
I tried to perform it in pgadming and worked.
Can I use it for NULL in each of the columns
Excellent and will be great 💪🏼 if there is a way to loop all tables in a specific Database 🤔😏
Thank you. May need to write a stored procedure to loop through all table names.
You can use EXEC sp_MSforeachtable, example for records count,EXEC sp_MSforeachtable 'SELECT ''?'' TableName, Count(1) NumRecords FROM ?'
Please share more SQL tips and tricks.
Sure. More sql tips coming soon.
Hi Mam!
Can you do some mesium/ hard videos on sql leet code questions please...
Sure. We are planning something soon. Stay tuned 👍
Nice ma'am..👍
Thank you
Nice Video.. But what if want to find only the Cancelled then in that case only two columns should appear..
It will output the whole record because we are performing a Select *.
How to make this work in oracle
If this does not work in oracle, then an or in where clause can always be used to compare each and every column value.
Select gold as Player,count(1) from events k
where not Exists (Select * from events p where k.gold=p.silver)
and not exists (Select * from events C where k.gold=C.BRONZE)
group by GOLD
Yes, this script is functional. But:
1. Dynamic queries are evil. Supporting such code is very time consuming
2. Code is vendor dependent and not portable
3. I can hardly imagine a situation where the table name is known in the database, but the column names are unknown or they can change arbitrarily. The above example shows that the base is not even in second normal form. This is not a base, but complete chaos. Instead of writing queries to this database, I would rather quit.
Thank you for your comments. They are always insightful and knowledgeable.
Yes, I agree this is not the best example of writing a code and should be used just as a quick trick for simpler requirements.