Questions tagged [tinyint]

tinyint is one of the Exact number data types that use integer data.

Integer data from 0 through 255. Storage size is 1 byte.

Type    Storage     Minimum Value   Maximum Value
        (Bytes)   (Signed/Unsigned) (Signed/Unsigned)

TINYINT   1          -128             127

Reference

101 questions
2
votes
1 answer

Update statement with TINYINT variables raises error in mySQL

I try to get a simple update query to work in mySQL, and I can't find an answer. What I try to do, for "agroforestry" is a tinyint variable : UPDATE Projects SET agroforestry = FALSE, WHERE project_id=2; This following query works perfectly on the…
Vinch Lao
  • 31
  • 1
  • 4
2
votes
2 answers

Mysql datatype for single digit - tinyint(1) or smallint(1) or int(1)

I need to add a column to mysql db table for storing single digits. The digits will be 0, 1, 2, and 3. What should be the datatype for the column? tinyint(1) or smallint(1) or int(1)?
Jeff
  • 235
  • 6
  • 16
2
votes
1 answer

Can I use resultset.getBoolean in Java to get Tinyint in SQL

Is it possible to use the rs.getboolean method to get the value of tinyint(0/1) out of SQL? like this: while (rs.next()) { boolean noUse= rs.getBoolean(1); } If this does not work, I suppose you have to do something like this: while (rs.next())…
2
votes
1 answer

MySQL converting to TINYINT

Under what circumstances will MySQL convert types to TINYINT? I know that a BOOL or BOOLEAN type in mysql DDL will automatically be converted to TINYINT(1) for for true or false. I am analyzing a database which has a type of varchar(16) on a field…
The Georgia
  • 1,005
  • 7
  • 23
  • 59
2
votes
3 answers

Converting TINYINT(1) to a string

I want to convert a TINYINT(1) value to string. Let's say if subscription paid is equal to 1 (or true) then the outcome will be "yes" when I retrieve the value from my MySQL database to my .php file. If subscription paid = 0 (or false) the the…
user3510657
  • 77
  • 1
  • 8
2
votes
2 answers

MySQL tinyint comparator returning empty set

I am doing a select statement trying to look for data where the column inactive is not set to 1, but the result is always Empty Set. Why is this happening? mysql> select id, time, num, inactive from data limit…
bvpx
  • 1,227
  • 2
  • 16
  • 33
2
votes
4 answers

Best practice for two tinyint columns that cannot be both 0

i have a question about the best practices about this situation: I have a mysql table that contains (besides the other columns) two columns that are both TINYINT(1) but they can't be both on 0, they can be 0 and 1, 1 and 0, 1 and 1 but no 0 and…
Phoenix_uy
  • 3,173
  • 9
  • 53
  • 100
2
votes
1 answer

MySQL TinyInt Value Won't Update

For the life of me I can't get php to update the schdl field in mysql. It will update EVERY other field in the test queries EXCEPT schdl . The schdl value is currently set to 1 and I am trying to set it to 0 . The schdl field's NULL option is set to…
2
votes
2 answers

Questions about char varchar and tinyint

I am working on a table for a registration form. Among it's fields/columns are: student_no (primary key) and age The student_no would hold values that have a fixed length of 9 characters that contain 8 numbers and a dash, for instance 11-423685,…
ransan32
  • 225
  • 2
  • 3
  • 9
2
votes
1 answer

MySQL, XML boolean values, and integers: Incorrect integer value:

Im working on grabbing xml data from ebay and putting the results into MySQL, Grabbing the data works fine, however inputting to database fails due to an incorrect integer value for a couple of the xml tags values. The xml tag value is the word…
MartinJJ
  • 337
  • 1
  • 6
  • 16
2
votes
2 answers

Converting data_type of many fields from bit to tinyint

Is the following query an acceptable way to convert the fields' data_types? UPDATE INFORMATION_SCHEMA.COLUMNS SET `COLUMNS`.`DATA_TYPE` = 'tinyint' WHERE `COLUMNS`.`TABLE_SCHEMA` = 'BAR' AND `COLUMNS`.`TABLE_NAME` = 'FOO' AND `COLUMNS`.`DATA_TYPE`…
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139
1
vote
1 answer

MySQL TINYINT negative numbers get converted to positive values

In my setup, I have a tinyint(1) column in mysql database table. I populated it with -1 but when I fetch the values via C# EF framework, the values were coming out to be +1.
gawkface
  • 2,104
  • 2
  • 27
  • 29
1
vote
2 answers

Is there a way to make an AND operation over a column of TINYINT(1) in MYSQL?

I got the following table and I need to return 1 if all rows have disponibilidad = 1 The following QUERY works just fine, but i was looking for a more efficient way of doing it. QUERY: SELECT IF(AVG(disponibilidad) < 1, 0, 1) AS newResult FROM…
1
vote
1 answer

How to prevent gorm from converting custom integer types into strings?

I have troubles while using gorm with custom types that have integer properties. Gorm tends to convert the integer values into strings for me. There are two separate problems: Problem 1: I have a custom type defined as follows: type ClientType…
Eric L.
  • 187
  • 1
  • 3
  • 10
1
vote
2 answers

How can I cast a TinyInt value from a SQL Server Table?

I have this SQL Server (Express) table: ...with a GenreId of TinyInt (there will only be a few dozen distinct Genres, at most). This C# code is failing, with "Specified cast is not valid." int genreId = 0; . . . genreId =…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862