I would like to subtract tow fields in table
for example Table1 has fields A, B, C
I wrote the statement as follows
Select A, B, (A-B) as diff from Table1.
MySQL is complaining that there is a syntax error near '-'
thank you
John 3 32843
John wrote: I would like to subtract tow fields in table for example Table1 has fields A, B, C
I wrote the statement as follows
Select A, B, (A-B) as diff from Table1.
MySQL is complaining that there is a syntax error near '-'
mysql> create table Table1(A int, B int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into Table1 values(4,2),(13 ,4),(8,6);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select A, B, (A-B) as diff from Table1;
+------+------+------+
| A | B | diff |
+------+------+------+
| 4 | 2 | 2 |
| 13 | 4 | 9 |
| 8 | 6 | 2 |
+------+------+------+
3 rows in set (0.00 sec)
mysql> select Version();
+-------------+
| Version() |
+-------------+
| 3.23.49-log |
+-------------+
1 row in set (0.02 sec)
mysql>
John wrote: I would like to subtract tow fields in table for example Table1 has fields A, B, C
I wrote the statement as follows
Select A, B, (A-B) as diff from Table1.
MySQL is complaining that there is a syntax error near '-'
mysql> create table Table1(A int, B int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into Table1 values(4,2),(13 ,4),(8,6);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select A, B, (A-B) as diff from Table1;
+------+------+------+
| A | B | diff |
+------+------+------+
| 4 | 2 | 2 |
| 13 | 4 | 9 |
| 8 | 6 | 2 |
+------+------+------+
3 rows in set (0.00 sec)
mysql> select Version();
+-------------+
| Version() |
+-------------+
| 3.23.49-log |
+-------------+
1 row in set (0.02 sec)
mysql>
John wrote: I would like to subtract tow fields in table for example Table1 has fields A, B, C
I wrote the statement as follows
Select A, B, (A-B) as diff from Table1.
MySQL is complaining that there is a syntax error near '-'
mysql> create table Table1(A int, B int);
Query OK, 0 rows affected (0.01 sec)
mysql> insert into Table1 values(4,2),(13 ,4),(8,6);
Query OK, 3 rows affected (0.00 sec)
Records: 3 Duplicates: 0 Warnings: 0
mysql> select A, B, (A-B) as diff from Table1;
+------+------+------+
| A | B | diff |
+------+------+------+
| 4 | 2 | 2 |
| 13 | 4 | 9 |
| 8 | 6 | 2 |
+------+------+------+
3 rows in set (0.00 sec)
mysql> select Version();
+-------------+
| Version() |
+-------------+
| 3.23.49-log |
+-------------+
1 row in set (0.02 sec)
mysql> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: |
last post by:
If I need to check if a certain value does exist in a field, and return
either "yes" or "not" which query would be the most effestive?
|
by: BigDadyWeaver |
last post by:
I am using the following code in asp to define a unique and
unpredictable record ID in Access.
<%
'GENERATE UNIQUE ID
Function genguid()
Dim Guid
guid = server.createobject("scriptlet.typelib").guid
guid=Left(guid,instr(guid,"}"))
genguid=guid
|
by: shumaker |
last post by:
I'm wondering how/why this query works. Trying to get my head wrapped
around SQL. Basically the Query deletes from the Import table all
records that are already in FooStrings so that when I do an insert from
the FooStringsImport table into the FooStrings table, then I won't get
primary key violations.
DELETE FROM FooStringsImport
WHERE...
|
by: dlx_son |
last post by:
Here is the code so far
<form name="thisform">
<h3>Enter time to add to or subtract from:</h3>
(If not entered, current time will be used)<br>
Day: <input name="d1" alt="Day of month" size=3>
Month: <input name="m1" alt="Month" size=3>
Year: <input name="y1" alt="Year" size=5> (4 digits for year, e.g.
|
by: GIS Analyst |
last post by:
Hi to all
I wish to be able to have a standard select statement which has
additional fields added to it at run-time based on supplied
parameter(s).
ie
declare @theTest1 nvarchar(10)
set @theTest1='TRUE'
| |
by: Downstreamer |
last post by:
Design is as follows:
A form for the user to input criteria to be used as the where part of
the report's recordsource. This includes a multiselect list box as part
of the criteria selection.
The report is generated from a button on this form. In the button's
onclick event a where clause is built and assigned to a public variable.
Because...
|
by: SueB |
last post by:
I currently have a 'mail-merge' process in my Access db project. It
generates custom filled out Award Certificates based on an SQL SELECT
statement in a VBA routine invoked by clicking on a command button.
The "problem": I want to conditionally insert some text into the award
certificate based on a field selected by the SELECT statement. ...
|
by: Charles Astwood |
last post by:
Hi, just starting out working my way round C Sharp and aspx.
Used to write all my sites in asp and just need a few pointers in how to
display data.
I have made a connection to my SQL2000 database with SqlConnection as I
think this is the fastest and best?
I have also written my SELECT statement, but am confused in how to display
this...
|
by: Remington |
last post by:
I am using windows 2000pro with access 2000.
I am trying to make a database for our HR department, that would allow our HR Director to type in an employee's ID number into a form and then select the dates the employee took off from work.
(I have the calander add-in 8.0 setup to easily select the dates already) There are two Date Fields,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |