Do table names with [Name1].[Name2] pattern differ from normal tables? [closed] - sql

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
When I look at Microsoft's sample AdventureWorks database, I see the table names follow a pattern such as:
[Person].[Address]
Does this kind of specification differ from a normal pattern such as:
PersonAddress
Is it only for readability or is there some other point to it?

It's SchemaName.TableName
So [Person].[Address] != PersonAddress
Instead it'll be Person.Address
The [] are optional, they exist because if you have special characters, or a reserve word in the object name, you will not be able to call the object without them.
For example select last name from people; is not going to work,
instead you need select [last name] from people;
You can find more information here.

Related

How to you use Max and Min expression in Ms Access SQL? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
CrimeData Table for 12 months
Crime Took place in Easternmost
I need to find the following:
Q.7 What type of Crime takes place in the …
(a) Easternmost ………………..
(b) Westernmost ………………..
(c) Northernmost………………..
(d) Southernmost………………..
I tried to find the crime took place in the Easternmost using the following SQL code
SELECT Max(CrimeData.Easting) AS MaxOfEasting, CrimeData.Type
FROM CrimeData
GROUP BY CrimeData.Type;
but I got more than one crime and also other Easting numbers. Can you please tell me if there are other good ways to find the solution.
Please see the attached pictures :)
Rather than using Max/Min, have a look at the TOP keyword in SQL. Some SQL might look like:
SELECT TOP 1 CD.*
FROM CrimeData CD
ORDER BY CD.Easting DESC;
Regards,

Structured Query Language [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Please explain some of these SQL code snippets to me:
select S.sid
from Student S
I don't know what the word "S" means after table name Student. Please give me a hand and explain.
S is an alias. Student S.
If you didn't specify an Alias, you could use:
select sid from Student
or select Student.sid from Student
The alias can be pretty much anything. E.G:
select aliasnameishere232fsdf.sid from Student aliasnameishere232fsdf
Alias's not only make query's easier to type, but can be useful for self-joins, for differentiation:
select S1.firstName, S2.firstName
from Student S1
JOIN Student S2 ON S2.someId = S1.someId
S is an alias. It's a shorter name given to Student in this query to make it easier to address.
It isn't very helpful in this particular query, but in longer and more complex queries, this technique really helps writing manageable code.

regexp_like vs like operator : Oracle [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
I am searching for multiple phrases using SQL 'like' operator. Same results can be extracted using Regexp_like function in Oracle. Which one is better/efficient to use and why? My observation is that 'like' works much quicker than regEX.
I am running my queries against very large dataset with few million rows.
Here are both the versions of the query
Using like:
select
name
from
table
where
lower(result) like '%the condition is absent%'
or lower(result) like '%partial presence of disease%'
Using Regexp_like():
select
name
from
table
where
regexp_like(lower(result),'^.*(the condition is absent)|(partial presence of disease).*$')

What does the 'cd' in a database column stand for? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
i.e. foo_cd or bar_cd where they are ints in the database representing some "type" or "flavor". I know the letters c and d stand for something but I can't remember what.
In rails as_enum :foo_type, {:flavorA => 1, :flavorB => 2, :flavorC => 3} would make the DB col foo_type_cd
It's a simple_enum table suffix that according to the author simply stands for code.
There is no standard meaning for cd, but from your excerpt I would expect that it is short for code
(bar_code, foo_code). Best practice would be to avoid such abbreviations.

Why does WordPress prefix its column names with the table name? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed last year.
Improve this question
I noticed that in a recent update WordPress decided to change all of its column names to include the table name prefix. WHY?!
The wp_posts table now has a column called post_title, for example. It used to just be title. I don't understand the reason for this change. There must've been one, yes?
I just don't understand what possible reason there could be since in SQL you can refer to things like table.column. Also, it must've been really difficult to change all of the code.
Perhaps to prevent confusion when making joins with tables having similar column names.
There is no good reason for doing this, plus it makes maintenance much more difficult.
There is no confusion if columns are specified like:
SELECT p.title, s.title FROM wp_posts p JOIN site s ON (p.site_id = s.id);