Home > Database > Mysql Tutorial > body text

How Can I Access Hyphenated MySQL Column Names from Java?

Linda Hamilton
Release: 2024-11-18 21:29:02
Original
636 people have browsed it

How Can I Access Hyphenated MySQL Column Names from Java?

Accessing Hyphenated Column Names in MySQL from Java

Despite searching extensively, you couldn't find a solution to accessing MySQL column names that contain hyphens. When attempting to use these names from Java code, the names break at the hyphen, causing them to become unrecognized. You've unsuccessfully tried substituting underscores in your code to resolve the issue.

To resolve this, you can enclose the column names within '`' (backticks) when referencing them in your Java code. This will allow you to access the columns without encountering the hyphenation error.

For example, if you have a column named 'air_port' in your MySQL database, you can access it in your Java code using:

ResultSet resultSet = statement.executeQuery("SELECT * FROM `air_port`");
Copy after login

The above is the detailed content of How Can I Access Hyphenated MySQL Column Names from Java?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template