Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL column type returns decimal or bigint when i run "SELECT 0 AS COL .."

Tags:

java

mysql

jdbc

When i run a select statment like

SELECT 0 AS COL FROM MYTABLE ..

Two different mysql installation returns different datatypes. One returns BIGINT second one is DECIMAL. for both cases jdbc driver is same and com.mysql.jdbc.Driver 5.1

Server Versions : 5.1.69-community (returns BIGINT) 5.6.31 (returns DECIMAL)

Is there any configuration difference? I must get BIGINT both for two installations. is it directly related with mysql version?

like image 429
bahtiyartan Avatar asked Oct 29 '22 22:10

bahtiyartan


1 Answers

You can force the issue with

 select CAST(0 AS UNSIGNED INTEGER) AS COL

Unsigned integers appear on the wire as BIGINTs.

like image 62
O. Jones Avatar answered Nov 09 '22 14:11

O. Jones