|
Recently, a very public comments section let me use "p*ssed (off)" (with the *) in a sentence. Surprised me too. It still maintains a cerain standard (IMO).
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Eh ?
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
It's a response to a deleted thread starter message: a pictogram of a stickman with a turd emoji for a head ...
If you check the "parent" indicator on the left when you hover you'll see it goes into the abyss.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I don't see the parent indicator on the original post
In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP
|
|
|
|
|
Hover your mouse over the message I wrote, and the "parent" indicator appears: a thin vertical line. If you follow it up, it points above all messages which indicates the thread started has been deleted. Normally it stops at the parent message.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
The other thing you can do is "View Thread" which displays a Message Closed message at the root.
|
|
|
|
|
So, what's your SQL resources for beginners and related to JOINs ?
I'm kind of stuck on request that should use JOIN and can't figure out how to make it work.
I somewhat understand how it works, but there's something missing in my understanding of the universe.
Thanks.
CI/CD = Continuous Impediment/Continuous Despair
|
|
|
|
|
|
If SQL Server... For simple things, you could try using SSMS' visual designer for creating a view.
|
|
|
|
|
Fresh from Eric Darling[^]. It talks about Joins.
Jack of all trades, master of none, though often times better than master of one.
|
|
|
|
|
Iβm not going to talk about right outer joins, because thatβs the foolish domain of characterless buffoons who use Venn diagrams to explain join results.
/ravi
|
|
|
|
|
I generally start with W3Schools SQL Tutorial[^] - they explain the basics, and provide DB samples and sandboxes so you can try it yourself without installing the heavyweight monster that is Sql Server.
Basically, SQL is a relational DB - it works with multiple tables to relate data to other data, unlike for example CSV which is a flat self contained file where all related data in combined into a single row.
So you can have an Invoices table (which holds the invoice date, customer, delivery address, and taxes / total owed) and a InvoiceLines table (which holds the items that were purchased: product, unit price, quantity, discount, Item total, InvoiceID).
To look at a whole invoice, you use a JOIN:
SELECT i.InvoiceDate, i.Total, i.PaidStatus, l.Product, l.UP, l.QTY, l.Disc, l.itemTotal
FROM Invoices i
JOIN InvoiceLines l ON l.InvoiceID = i.ID
WHERE i.ID = 123456 The InvoiceID relates the two bits of information and returns only the relevant data.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
I would second W3Schools! It has very helpful learning tools that I still rely on at times when I am trying to remember how to do something...
Steve Naidamast
Sr. Software Engineer
Black Falcon Software, Inc.
blackfalconsoftware@outlook.com
|
|
|
|
|
|
I was trying to work up the courage to suggest MS Access - fearing that same heck.
Bring your data, or let it build a template application for you.
Visually design your query, then change to the SQL view and figure out what it is doing.
You can write SQL that the visual designer cannot present (eg. sub-select).
You cannot write all SQL (eg. cartesian join).
Whilst you may not want to deploy it as an application (I have), it works to model or proof-of-concept for a business app.
b
|
|
|
|
|
MS Access...
Or anything that lets you visually design your query and then flip to SQL to see the SQL generated for what you did.
For a beginner, I think you'll pick up more and faster doing it that way than just googling/reading docs.
|
|
|
|
|
I find books with "Recipes" in the title useful; as in: "SQL Cookbook". The "Q&A" format (by "category") is the least time wasting when looking for a solution or insight into one.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
I'm not a database person myself, so I was probably in the same situation as you when it came to figuring out joins and stuff. I ended up creating a mental image that I found useful. For what it's worth, here it is:
JOIN = add columns of table B to the columns of table A getting a wider table.
columns used in join = imagine column from table A as "red" data and column from table B as "green" data
Arrange rows in table to have first those where both red and green data are equal. Continue with remaining rows in table A (only red data, green data is empty). Finish with remaining rows in table B (only green data).
Now:
- INNER JOIN = take only the first part where red and green are equal
- LEFT JOIN = take first two parts (the equal and other red rows)
- RIGHT JOIN = take first and 3rd parts (the equal and green rows)
- OUTER JOIN = take all.
Just my 0.02$
Mircea
|
|
|
|
|
My resources (which I suspect many, many database developers or software engineers that also develop T-SQL do in some form or fashion) are:
- Brain - by understanding and visualizing what the data design and queries/statements are doing helps eliminate a lot of bad ideas and wasted time.
- SSMS - still the most comprehensive and easiest to use, IMHO, though sometimes I use the DB tools in Visual Studio.
- SQL Server - I've tried others, but the support costs for multiple DB providers in the latter part of the SDLC for the customer are higher (in almost all use cases) that just using SQL Server correctly for the task at hand.
- Consistency - solving the same problem with the same design, unless a newer design is demonstrably better in terms of execution, resources, and supportability.
- CRUD - I limit my use of SQL Server (or any DB server) to CRUD (or in more common SQL terms, SELECT, INSERT, UPDATE, and DELETE) and leave the business logic to the C# code executing on the server or in the cloud app service. Database servers are designed to optimize reading and writing of data, not running business logic because it is easier to "just stick it all in the SQL".
|
|
|
|
|
"
what's your SQL resources
Brent Ozar.
|
|
|
|
|
If you're familiar with how joins work but are having problems figuring out how to use them in a particular query, it might be good to back up and look at the structure of the database you're working with. For instance, do you even have a good key to join on?
A poor DB structure with a lack of normalization can make joins difficult or even impossible. If that's the problem, one way around it is to throw the data into temp tables with the correct structure you need for the joins and query against that.
Speaking of which, in a addition to learning about SQL it's also a very good idea to learn the fundamentals of database design if you haven't already. Knowing about things like normalization, keys, and indexing really helps when writing SQL.
|
|
|
|
|
Wordle 983 3/6
π©β¬β¬β¬β¬
π©β¬π¨π¨π©
π©π©π©π©π©
|
|
|
|
|
Wordle 983 3/6
β¬β¬β¬π¨π©
β¬π¨β¬β¬π©
π©π©π©π©π©
|
|
|
|
|
Wordle 983 3/6*
β¬β¬β¬π©π©
β¬β¬π¨π©π©
π©π©π©π©π©
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|