Manixat Posted April 1, 2013 Share Posted April 1, 2013 Hello freaks, I have an insert query that uses a select query to find values to insert. To make it more clear I have around 4000 cities stored in a database and when a user registers the name of the city is sent to PHP but I need to record the ID and then my query looks something like this INSERT INTO `users` (`blablabla`,`blablabla`,`CITY`) VALUES (`blablabla`,`blablabla`,(SELECT `ID` FROM `cities` WHERE `Name`='$phpvariable')) The problem is that it retrieves cities up to ID 127. I suppose that is due to the data limit of TINYINT. My question is how do I get around that, or in other words how can I change the data type the SELECT query returns ? Link to comment https://forums.phpfreaks.com/topic/276401-select-returns-ids-up-to-127/ Share on other sites More sharing options...
Barand Posted April 1, 2013 Share Posted April 1, 2013 Changing it in the query won't increase the capacity in the table. You need to ALTER the table and make it INT type Link to comment https://forums.phpfreaks.com/topic/276401-select-returns-ids-up-to-127/#findComment-1422352 Share on other sites More sharing options...
Manixat Posted April 1, 2013 Author Share Posted April 1, 2013 Sometimes I just sit and wonder how can I be that much of a retard.. The problem was that I was thinking my field was INT type and the query was for some reason returning tinyint... Link to comment https://forums.phpfreaks.com/topic/276401-select-returns-ids-up-to-127/#findComment-1422353 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.