sql select

A Java MySQL SELECT example

Summary: This is a Java/MySQL SQL SELECT example, demonstrating how to issue a SQL SELECT command from your Java source code, using a MySQL database.

Spring Dao - JDBC SELECT statement examples

Spring JDBC/Dao FAQ: Can you share some Spring JDBC examples, specifically SELECT query examples using Spring Dao objects?

Sure. I've done a lot of work with Spring lately, and I love the Spring Dao approach, so this page is a collection of Spring JDBC SELECT query examples (Spring DAO examples) from a real-world Java project I've been working on. In each example I try to show each type of SQL SELECT query that I've used in that project, with a brief explanation before each SQL query.

A Spring JDBC SELECT and INSERT example

A Spring JDBC SELECT and INSERT example: Here's the source code for a complete Spring DAO class from a project that I'm currently working on (a Java-based web interface to the open source Nagios project) that shows how to use a few Spring JDBC methods, including both a SELECT example and a simple INSERT example.

I'll add more examples to this site later (and with more introduction/description), but for now I'm just going to drop this Java class sample out here and hope that it helps you "Learn Spring JDBC by example".

A Java PreparedStatement example with a SELECT statement and LIKE clause

Here's a quick example of how to use a JDBC PreparedStatement with an SQL SELECT query when accessing a database. To make it a little more complicated I added a LIKE clause to the SELECT statement. So, this is really an example of a PreparedStatement that uses a SELECT query that uses a LIKE clause.

Postgres regex - Using regular expressions in queries

Postgres regex support. Some time ago I learned that about Postgres regular expression searching, including Postgres case insensitive searching.

If you're familiar with Unix and Perl regular expressions, these are very similar, so it's an easy pickup, and a very powerful way to search for data in Postgres. Just use these regular expressions with SELECT in your PostgreSQL queries instead of the LIKE operator, and you're ready to go.

A SQL "select where date" example

Here's a quick "SQL select where date" example, showing how to select all orders from an example orders table where the order_date is greater than a date we specify.

The SQL "select where date" example

With these assumptions:

  • You have a database table named orders
  • This table has two fields named order_id and order_date

This SQL will give you information about orders placed in the last two days with PostreSQL:

Syndicate content