This question already has an answer here:
Relational Algebra check for error
(1 answer)
Closed 7 years ago.
Is there a way to display a sql LIKE-operator in relational algebra?
right now I have done it like this:
Ďfirstname LIKE ('B%')person
But I'm not sure if this is the right way to go.
Thanks in advance for the help.
Here is a similar question covered earlier on this site regarding how to use LIKE in relational algebra. In that case, the professor had indicated that it was ok to use LIKE just as in SQL.
Related
This question already has answers here:
What is the meaning of <> in mysql query?
(7 answers)
Closed 3 years ago.
I know this is a really beginner question, but I don't know what the meaning of this. I'm reading the existing system code. I don't know what does this symbol means <> in Query Builder.
Here is the sample code:
$builder = DB::table('product');
if (isset($product->type)) {
$builder->where('product.type', '<>', $product->type);
}
Thanks!
In MySQL syntax, this is the same as not equal or !=.
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 5 years ago.
Improve this question
So this isn't a technical question, but rather questioning why a language is designed the way it is.
I've been learning SQL and one thing that's been bothering me greatly is how SQL asks you to name the column you want and THEN name the table you want to get it from. To me, it would make more sense that you refer to the parent body (which is the table) and THEN the column it has. But SQL seems to forces users to do it the other way around. Why?
I'm just curious as to why the language is designed this way.
SELECT column
FROM table
why not
FROM table
SELECT column
SQL tries to mimic English language to some extent, so that it feels natural to formulate the query.
In spoken English you would say something like "I want the names of the employees". You would not say "I want of the employees their names" or something like that.
But you are right, it might have been a good idea to have the query represent the order of execution. And "From the employee table I want the names" would not be so far off the mark :-)
SQL is a descriptive language, not a procedural language. It describes the result set being produced. And, you can think of that result set as a report, with column headers.
As such, the basic querying construct returns those column headers. The rest of the query describes how they are produced.
You may find this post useful. Starting with FROM is the most logical way to think about a query (Why would anyone write SELECT before knowing what to SELECT from?). However, SQL guidelines were designed as if your query were a command. Thus, you are commanding the system to SELECT the data for you, and the FROM further specifies that command.
Of course, the actual execution is distinct from the lexical and logical orders above.
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Split Function equivalent in tsql?
I have a column that contains data in the form:
CustomerZip::12345||AccountId::1111111||s_Is_Advertiser::True||ManagedBy::3000||CustomerID::5555555||
Does SQL have any sort of built in function to easily parse out this data, or will I have to build my own complicated mess of patindex/substring functions to pull each value into its own field?
I don't believe there is anything built in. Look at the comments posted against your original question.
If this is something you're going to need on a regular basis, consider writing a view.
This question already has answers here:
How to search for a comma separated value
(3 answers)
Closed 8 years ago.
I have data in table in below format
id brand_ids
--------------
2 77,2
3 77
6 3,77,5
8 2,45,77
--------------
(Note the brand ids will be stored like comma separated values, this is common for values in this field)
Now i am trying to get a query which is capable of querying out only rows which have '77'
in it..
I know i can use LIKE command in three formats LIKE '77,%' OR LIKE '%,77,%' OR LIKE '%,77' with or condition to achieve it. But i hope this will increase the load time of the sql.
is there any straight forward method to achieve this? if so please suggest.
Thanks,
Balan
A strict answer to your question would be: no. Your suggestion of using LIKE is your best option with this data model. However, as mentioned, it is highly suggested that you use a more normalized model.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
What is the n+1 selects problem?
what is N+1 type queries ?
i don't know what is this?
there is nothing like N+1 type query
areyou talking about this -->
What is SELECT N+1?
see here:
What is SELECT N+1?
:)