using a calculator in mysql
need to perform some maths operations while working on mysql ?
Do you use bc or some other application.
Here is how my friend Nir hacked mysql …
mysql> 816-528
ERROR 1064: You have an error in your SQL syntax near ‘816-528′ at line 1
mysql> select 816-528 from any_table_name;
| 288 |
| 288 |
| 288 |
+———+
834 rows in set (0.01 sec)
mysql> select distinct(816-528) from any_table_name;
+———–+
| (816-528) |
+———–+
| 288 |
+———–+
1 row in set (0.01 sec)
Bingo!
its good enough for +. - . *, / etc. you rock Nir.
Todays link : Google Ranking Factors
and BSE@7800 






August 3rd, 2005 at 5:32 pm
Re:
This is height of ‘bc’ :))
If one is so fond of ‘bc’ on mysql he could could just type
select operation ,where operation would be evaluated.
August 3rd, 2005 at 7:00 pm
Re:
try this..
mysql> select mathematical_expression from dual;
btw what is this google ranking factor ??
August 3rd, 2005 at 8:25 pm
Re:
“select operation”
that looks like a feature… and what nir did was hacking…
“from dual”
some_database.dual doesn’t exist. must be some oracle stuff.
link is corrected now. some google heuristics for page ranking.
August 3rd, 2005 at 11:15 pm
Re:
Where is hacking in this????
select ‘from’ a table returns all its tuples, the SQL query parser has the ability to evaluate expressions, and using distinct you rule out duplicates.
August 4th, 2005 at 5:48 pm
about dual dual from dual;
select
is a sql query that operates on a dummy table ‘dual’ created in oracle just for the purposes other than data selection. one is the mathematical operation that you have ‘hacked’. other use is to return empty tuples to the user.
My search indicates:
From MySQL 4.1.0 on, you are allowed to specify DUAL as a dummy table name in situations where no tables are referenced:
mysql> SELECT 1 + 1 FROM DUAL;
-> 2
DUAL is purely a compatibility feature. Some other servers require this syntax.