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 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. 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. 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. 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? 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? 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>"; } ?> 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 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 Link to comment https://forums.phpfreaks.com/topic/138196-solved-selecting-numeric-values/#findComment-722540 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.