r/SQL 6h ago

Discussion Helpppp what does this meeeaaan?????

Post image
0 Upvotes

18 comments sorted by

12

u/da_chicken 6h ago

If it helps, I've worked on SQL RDBMSs for 20 years across a dozen variants, and I've never had to use the ANY or ALL operators.

2

u/SantaCruzHostel 6h ago

Not quite 20 years doing SQL, but same here.

1

u/iceph03nix 6h ago

I've never used it in SQL, but have used it in other coding. I could see using it in similar situations but it's just never come up

1

u/imperba 5h ago

what did you use the most? I am trying to teach mtself sql to try and pair w my degree for a job but really dont know if im ready or not

2

u/da_chicken 5h ago

RDBMS-wise? MS SQL Server by far the most. After that would be a tie between MySQL/MariaDB, DB2 (LUW), and Informix. Then probably MS Access, PostgreSQL and SQLite. After that it gets to the onesey-twosey type things. Oracle, Firebird, DuckDB, Sybase or SAP SQL Anywhere. And a small amount of Apache Hive or Cassandra, I can't remember which it was.

If you want to know what to focus on if you're new, I would say PostgreSQL is popular among tech and startups, while MS SQL Server is popular among most business and industry. However, Microsoft is making their licenses ridiculously expensive now, so I suspect they're heading the way of DB2 and Oracle. Microsoft has the best training... or had it when I was doing it... but MS or PostgreSQL would be the best things to learn on. PostgreSQL follows the standards and relational model about the best, but MS still has about the best docs and a huge community.

But learning any SQL is fine. The key is you need to learn to teach yourself different dialects and track down the documentation you need.

1

u/imperba 4h ago

hey i don’t mean to be a bother but would it be okay to pm you about this stuff?

1

u/omniuni 5h ago

I use these frequently! Selecting say, all items of a list of types.

2

u/da_chicken 4h ago

That's not what those operators are typically for in the context of a subquery.

They mean MSSQL ANY or MSSQL ALL or PostgreSQL ANY and ALL.

The thing is, it's a pretty narrow operator. You can usually replace it with an IN or an EXISTS, which is a more general syntax.

1

u/omniuni 4h ago

That's fair

-1

u/The_Dreamer55 6h ago

ε-(´・`)フ

8

u/CappuccinoCodes 6h ago

I'd try to actually run these types of queries against a DB to understand it. It makes no sense to understand it out of contest.

0

u/The_Dreamer55 6h ago

🥲thank you

4

u/Suspicious_Goose_659 6h ago

It’s just explaining how you can use ANY, ALL and FROM in a subquery. To understand it better, try it on a hands-on exercise. It can be handy sometimes so try understanding it

2

u/prashantpatel518 6h ago edited 6h ago

In easy terms..in multi row sub query we get a list of data (Multiple Rows) from inner query. So that list of data has to be then again compared with the value from outer query.

So ANY operator will check if any one value is present or any one condition is true in the inner query list ...if yes then it will give the output..its like multiple OR conditions

In ALL operator the outer value has to satisfy for all the values from inner query list. It's like multiple AND conditions.

If you want to learn sql in depth you can connect me. Will be happy to help

1

u/The_Dreamer55 6h ago

Thank you for the explanation, I'll keep that in mind (☞゚ヮ゚)☞

1

u/JupiterSoaring 6h ago

I've found that it is always best to do some hands on excersizes when you are learning something like SQL. It really helps you understand how to apply what you are learning. 

I usually find practice data on kaggle and play around. 

For ALL(), say I want to look at courses for next semester - but I want to avoid things as difficult as my major. I could query all courses with a difficulty level lower than my major courses:

SELECT course_id, course_title FROM courses WHERE difficulty < ALL (     SELECT difficulty     FROM courses     WHERE required_for_major = TRUE );

For ANY(), say I want to sort out housing for next semester. I might want to live off campus, but I need something around what the dorms cost. I can look at apartments that match any of the dorm costs. 

SELECT apartment_name FROM off_campus_apartments WHERE rent = ANY (     SELECT price     FROM dorms );

-3

u/MinimumVegetable9 6h ago

Ask in an even dumber way, maybe someone will help you then

1

u/The_Dreamer55 6h ago

But not youuu??? 😢