Hello to everyone.

I am new in the forum, and my first post is going to be about mySQL. I am a total novice in mySQL and the problem i have is that i want to put a specific filter in reading some data.
I have created a database with one table, which has 4 columns, let's say C1, C2, C3, C4.
I have created the interface in java, through which the data is inserted in the dbase.

String insertStr =
				"INSERT INTO `"+dbName+"`.`"+tableName+"` VALUES (CURRENT_TIMESTAMP , '"+
					m.get_C1() + "', '" +	
					m.get_C2()+"', '"+
					m.get_C3()+"', '"+


Now, i want to start reading the data, in a specific way:
I want to read the C1,2,3,4 data of the line in which has C1=1 and the C2 is the maximum. Actually, i want to know C3,4 of this line through this filter.
the SELECT i am going to make is of that type:

String selectStr=
SELECT data1, data2, data3 FROM 'dbName'

The problem is how i am going to put a filter in this.
Also, is there a spexific code through which i can assign the data in java to some values?

Sorry if my long post was tiring, i hope somebody can give some help.
Thanks in advance,


9 Years
Discussion Span
Last Post by javmedia

Dont filter in the external application as it is faster to issue constraints in your calling query in this case.

using PHP style for readability

"SELECT `c3`,`c4`
 FROM `MyTable`
 WHERE `c1`='$c1Value' AND `c2`='$c2Value'
 LIMIT $maxDisplayedResultsCount;"

or for range

"SELECT `c3`,`c4`
 FROM `MyTable`
 WHERE (`c1`>='$c1ValueMin' AND `c1`<'$c1ValueMax') AND `c2`='$c2Value'
 LIMIT $maxDisplayedResultsCount;"

On the JAVA part you lost me... :)

Or did you mean filter before INSERT or filter on new SELECT statement?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.