MySQL query: Select only numeric substring from Varchar field?

2013-07-03  Source: Original Site  Category:PHP  Views:0 

Advertisement

I would like to write a MySQL query that will limit the selected records to a specific pattern that end in digits rather than non-numeric characters.

Say the field (TESTPHASE) has values like this
A000
APM
APM1
A015
A010
A045
HPM1
GPM
F020
E045

I want the SELECT query to return only

A000
A015
A010
A045
F020
E045

I suppose it would be possible to filter these after the fact with some fancy php code, but I'd MUCH rather do it up front with the MySQL query.

Oh, and of course I am stuck with MySQL v3.23.45

Any suggestions?

Related articles
  • MySQL query: Select only numeric substring from Varchar field? 2013-07-03

    I would like to write a MySQL query that will limit the selected records to a specific pattern that end in digits rather than non-numeric characters. Say the field (TESTPHASE) has values like this A000 APM APM1 A015 A010 A045 HPM1 GPM F020 E045 I wan

  • MySQL Query selecting only distinct 2013-01-17

    I have a query: mysql_query ("SELECT title FROM forums.topics WHERE topicID IN (1,1,3) ORDER BY FIND_IN_SET(topicID,'1,1,3')"); I have the two duplicate ids (1) and so when I do the query it only returns the row once. I need to have all rows returned

  • Selecting only integer values from a field 2013-02-14

    I have a field that has integer and non-integer data. For just this one query, I need to select out only the integer values. How do I make a query ingore any value that has a decimal attached? (I don't need to round... I only want to select the whole

  • select only 100 characters from a field 2013-02-17

    say i have a table that holds a lot of text. on one of my pages, i only want to display the first 100 words, then a 'click here to read more...' link. how would I do that? How do i limit the number of characters displayed/selected to a certain number

  • How to fetch only first 6 numeric values from varchar column 2015-02-15

    Someone please help to write query for below screnaio. I want to fetch only first 6 numeric values from varchar column using below conditions. Conditions are, 1. Substring only first 6 numeric. 2. If any substring output has alphabet ignore the alpha

  • Selecting only certain Rows from a SQL DB 2012-10-26

    Im trying to select only certain rows from a sql DB, say i have 100 rows, every row has a field called "category" and theres 4 different categories. lets say i want to select all the rows from just category "widgets" What is the php command for this?

  • Oracle select only 5 rows from a table 2015-01-05

    How can I select only 5 rows from my table SELECT tbl_employee where tbl_employee.lastName = 'Smith'

  • MySQL Selecting only 1 row from a subquery 2014-11-25

    Hi, I am new to mySQL and I am trying to select a list of "artists" and then only 1 picture from the related table "artists photo", how am I able to do this? so far I get the list of artists with all the photos, I tried using subqueries but I dont re

  • MySQL return only numeric values in a field 2014-05-25

    I need a query that will return only rows with numeric values in one of the fields pseduocode: SELECT name, address, zip from information_table where address contains only 0-9 As far as I have read, mysql only has regex match capablities, not regex r

  • MySql Query "Select AND / OR / MATCH Problem ! " 2013-03-17

    I am currently having a problem with a SELECT mysql_query... I need my mysql query with select statement to return only queries that match the customers id variable that I assign, then be able to search other columes within the table that have that c

  • mysql query using php to pull from multiple tables 2012-06-27

    I am having trouble simplifying my mysql query. I have 3 tables I need to verify data in before I add new data to it. The code is as follows: (this takes place after all validation of form data has been completed.) if (empty($errors)) { //If all is o

  • Oracle select a numeric-substring 2013-04-03

    I'm novice with Oracle and I hope you can help me I have a String like these: '8765432-S' or 'W-12345698-R' rand I would like to know if exists a way to do a SELECT only with the numeric number. i.e. only with '8765432' or '12345698'. I can't use SUB

  • How to pick only Numeric values from oracle table. 2013-04-30

    I have a column which contains both numeric and alphanumeric data. I want to fetch only the numeric data from that column. table have data like: 1a 1 2 d2 f My query should return only 1,2 not any other value.Any help in this matter is higly apprecia

  • Oracle selecting only essential columns from user_tab_columns table 2014-11-03

    How to select onlt those columns from all_tab_columns table for a particular table say 'TAB' excluding few columns. e.g. A table 'TAB' from USE_TAB_COLUMNS required columns only co1,col2,col3 not required col4,col5 How to write a query to select only

  • How to turn a mySQL query into a numerical array? 2015-05-19

    How can I turn a mySQL query into a numericaly indexed array? Let's say I have this query: $query = "SELECT name FROM table"; Now, I know how to setup a while loop to assign all the rows to a single variable and display them one right after the other

  • Oracle Need to get only numeric values from the Varchar2 data type column 2012-03-15

    Gurus, I have a table column with the VARCHAR2 data type. The values in the Column are 100 A200 300 B400 500 600C I need a query which only fetches the numeric values like 100 300 500 How can i achieve this? Please help in this. Thanks in Advance.

  • MySQL Query selecting corresponding data between tables 2012-11-23

    I need to translate a db field in one table to it's corresponding table in the same database. (ID# coverted to corresponding name is other table). I have 2 fields that correspond to the same data in another table. Here's the code: $query = "SELECT a.

  • Selecting Only 1 Product From A Database ... 2013-03-31

    Please can any one help me on selecting the product name from a database only once e.g. if a search is performed for a AMD and there is 2 AMD XP 1800+ in the database then it would only display one of them. My code is: result = mysql_query("SELECT *

  • Oracle How can select only 2 partitions from a table 2014-04-29

    I was trying to select only from 2 partitions in a table so I used select * from tab1 partition(part1,part2); But it is not working.Any ideas??

  • Select only last record from a table 2014-08-15

    I have a problem that I just can't seem to work out. I am fairly new to PHP so sorry if this question seems lame. I am trying to work out what the MySQL query would be to only retreive the last row in a table. There is an auto number assigned wheneve