krv Posted December 23, 2008 Share Posted December 23, 2008 hello, I am trying to select only certain numbers from a table. Example: I have a parts table one of the rows in skew #'s the skews are from 1000 to 9000 how would i select just 2000's and 8'000s? thanks Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/ Share on other sites More sharing options...
Maq Posted December 23, 2008 Share Posted December 23, 2008 Something like (syntax may be off): SELECT part_num FROM table WHERE (part_num > 1999 AND part_num 7999 AND part_num You could use 2 between clauses as well. Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722497 Share on other sites More sharing options...
krv Posted December 23, 2008 Author Share Posted December 23, 2008 ha oh yeah duh... i was trying to do something with substr() Thanks man. Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722500 Share on other sites More sharing options...
Maq Posted December 23, 2008 Share Posted December 23, 2008 Sure, I'm pretty sure my syntax is off, but I'm sure you'll figure that out soon enough. Post any more problems, if not mark as solved please. Good luck. Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722506 Share on other sites More sharing options...
krv Posted December 23, 2008 Author Share Posted December 23, 2008 weird so tried doing it and i did different numbers then the example im getting data like: 96541-1 96542-1 96543-1 96544-1 96545-1 96546-1 96547-1 96548-1 96549 96565 96566 96567 96600 96602 96603-1 96604-1 96605-1 96607 96608 96694 any functions to clean that up in sql? Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722509 Share on other sites More sharing options...
Maq Posted December 23, 2008 Share Posted December 23, 2008 any functions to clean that up in sql? Yes. Can you post the relevant code? Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722513 Share on other sites More sharing options...
krv Posted December 23, 2008 Author Share Posted December 23, 2008 <?php //23/12/2008 include("includes/config.php"); $sql = "SELECT part FROM products WHERE part >6999 AND part <8000 OR part >8999 AND part >10000"; $result = mysql_query($sql)or die(mysql_error()); while($row=mysql_fetch_array($result)){ echo $row['part']."<br>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722514 Share on other sites More sharing options...
krv Posted December 23, 2008 Author Share Posted December 23, 2008 figured it out using part BETWEEN '6000' AND '6999' thanks for your help Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722536 Share on other sites More sharing options...
Maq Posted December 23, 2008 Share Posted December 23, 2008 After thinking about your problem I thought that between would be more suitable. Glad you got it working, please, if your issue is resolved mark as solved Quote Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722540 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.