Manixat Posted April 1, 2013 Share Posted April 1, 2013 (edited) 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 ? Edited April 1, 2013 by Manixat Quote Link to comment Share on other sites More sharing options...
Solution Barand Posted April 1, 2013 Solution 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 Quote Link to comment Share on other sites More sharing options...
Manixat Posted April 1, 2013 Author Share Posted April 1, 2013 (edited) 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... Edited April 1, 2013 by Manixat Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.