What are the academic names for the left and right operands in binary relational operator? - operators

Relational operators such as <, >=, == are often not bidirectional. What are the correct names for the operands to these operators? An example from an non-relational operator, division, would be the operand names divisor and dividend.

Comparand for either operand.
An operand of an equality/inequality is referred to as a comparand in some mathematical, linguistic & computing contexts. Google 'comparand' with 'math', 'linguistics', 'ibm', 'intel', 'microsoft' or 'site:stackoverflow.com'.
(It's not in the OED or Merriam-Webster. It's in the Wiktionary.)
(For 'linguistics' Google even finds a comparee & comparand.)

Comparand is the word used for operator and Comparanda is the word used for things being compared. But the most practiced word is still Comparison Operator.

Related

SQL string comparison, greater than and less than operators

Today I viewed some query examples, and I found some string comparisons in the WHERE condition.
The comparison was made using the greater than (>) and less than (<) symbols, is this a possible way to compare strings in SQL? And how does it act? A string less than another one comes before in dictionary order? For example, ball is less than water? And this comparison is case sensitive? For example BALL < water, the uppercase character does affect these comparison?
I've googled for hours but I was not able to find nothing that can drive me out these doubt.
The comparison operators (including < and >) "work" with string values as well as numbers.
For MySQL
By default, string comparisons are not case sensitive and use the current character set. The default is latin1 (cp1252 West European), which also works well for English.
String comparisons will be case sensitive when the characterset collation of the strings being compared is case sensitive, i.e. the name of the character set ends in _cs rather than _ci. There's really no point in repeating all of the information that's available in MySQL Reference Manual here.
MySQL Comparison Operators Reference: http://dev.mysql.com/doc/refman/5.5/en/comparison-operators.html
More information about MySQL charactersets/collations: http://dev.mysql.com/doc/refman/5.5/en/charset.html
To answer the specific questions you asked:
Q: is this a possible way to compare strings in SQL?
A: Yes, in both MySQL and SQL Server
Q: and how does it act?
A: A comparison operator returns a boolean, either TRUE, FALSE or NULL.
Q: a string less than another one comes before in dictionary order? For example, ball is less than water?
A: Yes, because 'b' comes before 'w' in the characteset collation, the expression
'ball' < 'water'
will return TRUE. (This depends on the characterset and on the collation.
Q: and this comparison is case sensitive?
A: Whether a particular comparison is case sensitive or not depends on the database server; by default, both SQL Server and MySQL are case insensitive.
In MySQL it is possible to make string comparisons by specifying a characterset collation that is case sensitive (the characterset name will end in _cs rather than _ci)
Q: For example BALL < water, the upper case character does affect these comparison?
A: By default, in both SQL Server and MySQL, the expression
'BALL' < 'water'
would return TRUE.
In Microsoft SQL Server, collation determines to dictionary rules for comparing and sorting character data with regards to:
case sensitivity
accent sensitivity
width sensitivity
kana sensitivity
SQL Server also includes binary collations where comparison and sorting is done by binary code point rather than dictionary rules. Once can choose from many collations according to the desired sensitivity behavior. The default collation selected for Latin-based language locales during SQL installation is case insensitive and accent sensitive.
Collation is specified at the instance (during installation), database, and column level. Instance collation determines the collation of Instance-level objects like logins and database names as well as identifiers for variables, GOTO labels and temporary tables. Database collation (same as instance collation by default), determines the collation of database identifiers like table and column names as well as literal expressions. Column collation (same as database collation by default) determines the collation of that column.
It is certainly possible compare strings using '<', '>', '<>', ,LIKE, BETWEEN, etc.
if you are using Mybatis or XML based technique to execute SQL query, you have to use <![CDATA[your_symbol-here]]> to avoid that issue.
'ball' <![CDATA[<]]> 'water'
Look at the interesting output by SQL Server. The code was to compare the dates, it works fine all the time, but fails when year changes.
SELECT TOP 1 'The ResultSet should be empty' FROM SYS.columns
WHERE '01/04/2023' < '07/11/2022'

How does Sql compare values?

Sql has a variety of operands that can check values and return results based on a variety of criteria. The equals (=) is one of these operands and is defined by Microsoft as something that
Compares the equality of two expressions
How does sql do this? I would assume that the values being compared are converted to ascii or unciode and these values are compared rather than the user-entered values. However, sql generally defaults to being case insensitive, while ascii, for example, assigns different numberical representations depending on the case. Is there a general method that sql uses for value comparisons? Is the method standard across platforms?
Comparison operators test whether two expressions are the same. Comparison operators can be used on all expressions except expressions of the text, ntext, or image data types. The following below links the Transact-SQL comparison operators.
http://msdn.microsoft.com/en-IN/library/ms188074.aspx
OR
http://beginner-sql-tutorial.com/sql-like-in-operators.htm

Logical and bitwise operators VB

According to MSDN The And operator can act as a bitwise operator OR a logical operator.
The only way to know if it is used as One operator or another is, If it is on the right side of an assignment operation? for example x = 3 AND 5. I cannot find any other instances where the bitwise operator would be used instead of the logical operator, are there? Thank you for you help.
Update: I guess you can do it inline if you needed to
Response.Write(CLng("3") And CLng("4"))
It is a logical operator when the operands are both of type Boolean. Bitwise operator in any other case, albeit that I'm not trying to think of Nothing. Also consider OrElse and AndAlso, they are always logical and do short-circuit evaluation.

Are "charlist" style wildcards part of the SQL-92 standard?

The SQL wildcards "%" and "_" are well documented and widely known. However as w3schools explains, there are also "charlist" style wildcards for matching a single character within or outside a given range, for example to find all the people called Carl but not those called Earl:
select * from Person where FirstName like '[A-D]arl'
... or to find the opposite, use either:
select * from Person where FirstName like '[!A-D]arl'
or (depending on the RDBMS, presumably):
select * from Person where FirstName like '[^A-D]arl'
Is this type of wildcard part of the SQL-92 standard, and what databases actually support it? For example:
Oracle 11g doesn't support it
SQL Server 2005 supports it, with the negation operator being "^" (not "!")
The SQL-99 Standard has a SIMILAR TO predicate which uses "charlist" style as well as the "%" and "_" wildcard characters.
Nothing similar (no pun intended) in the SQL-92 Standard, though.
The "charlist" operators look like regular expressions, or a limited subset of them. AFAIK there's no regular expression syntax specified in SQL-92 although many databases support regex's, and HOW they support it varies. Oracle, for example, has functions to do regular expression comparisons and substitutions. Don't know how others do it.
Share and enjoy.

mysql database populate

How should we treat the data if they have no values in it. I mean, at some places, they have no value. Should we populate it as it or should we write something at that place?
The concept of the NULL value is a common source of confusion for newcomers to SQL, who often think that NULL is the same as an empty string '', or a value of zero.
This is not the case. Conceptually, NULL means "a missing unknown value" and it is treated somewhat differently from other values. For example, to test for NULL, you cannot use the arithmetic comparison operators such as =, <, or <>.
If you have columns that may contain "a missing unknown value", you have to set them to accept NULLs, and use a NULL value as #codaddict suggested in the other answer.
You need to use a special value called NULL in such cases.