tags:

views:

42

answers:

1

What is the code for an equal function?

This values in this column and the values in this column and the values in this column all equal this column.

A: 

Your question is a bit vague but I'll assume you mean "How do you do this in SQL?"

Columns in the same table

SELECT column1, column2, column3, column4 FROM myTable
WHERE column1 = column4
AND column2 = column4
AND column3 = column4

If on the other hand you meant to compare the total values of columns 1, 2 and 3 to column4 it would look like:

SELECT column1, column2, column3, column4 FROM myTable
WHERE column1 + column2 + column3 = column4

You can learn a lot more about SQL's syntax by taking a look at http://www.w3schools.com/sql

codeelegance
Yes that is what i mean and thank you for your input!!
Jeff Anderson
Then feel free to mark my answer as accepted. :-)
codeelegance
Will this code have columns 1-3 added up and then the total of columns 1-3 will result/show up in column 4?
Jeff Anderson
No. It simply compares columns 1, 2 and 3 with 4 individually. So the only records that would be returned would be ones in which all four columns are equal.
codeelegance
So do you know what code would make it do that? Make it so i can have 5 columns and 5 rows of information, and then if i want to have it put a Sum result in a seperate box of just column 1 and row 1 information??
Jeff Anderson
You really should take a look at http://www.w3schools.com/sql/. It's a whole lot easier to know what you want to do and just do it than try to explain it to someone over the internet and hope they understand.
codeelegance

related questions