how to retreive last number in the data [duplicate] - php

This question already has answers here:
How to retrieve the last 4 characters from a mysql database field?
(4 answers)
Getting last 5 char of string with mysql query
(6 answers)
Query to select strings end with certain character
(6 answers)
Closed 5 years ago.
this is my data in the database and i'm using mysql
database image
How do I retreive number "4" from the data using sql command?

USE reverse and left
set #myfield = 1234;
select left(reverse(#myfield),1) as result;
result
4
demo here
http://rextester.com/LTBE34983

Related

add INT with STRING in PHP [duplicate]

This question already has answers here:
Getting a number when it has certain prefix from a block of text in PHP
(3 answers)
Zero-pad digits in string
(5 answers)
Closed 1 year ago.
I am trying to add the int with strings in PHP but I could get a helpful answer on StackOverflow and other website communities.
I want the code separate the ALPHABETS and NUMBER and then add the value in NUMBER and again JOIN the ALPHABETS AND ADDED NUMBER together.
How I achieve this, Please help.
Example:
$mynumber = 'SBI0001';
$addValue = '1';
It will be 'SBI0002' in PHP.

How to show last data with created date? [duplicate]

This question already has answers here:
SQL select only rows with max value on a column [duplicate]
(27 answers)
Retrieving the last record in each group - MySQL
(33 answers)
Closed 3 years ago.
I have a problem to show one of duplicate data with last created date. This is is my query :
$sqlpur ="SELECT DISTINCT pn, created_date, id_purchase FROM pur_supp ORDER BY pn, created_date DESC";
This is the result.
This is a data from database.
But, I want to show just one of duplicate data. an example just to show 02N64073 with last created Date.

Mysql escape ' and \ [duplicate]

This question already has answers here:
How can I prevent SQL injection in PHP?
(27 answers)
Closed 4 years ago.
How can I select a row in MySQL db where the value of a column contains ' and \ ?
For example, I want to select a column that matches this types of string:
https://www.mayoclinic.org/diseases-conditions/hirschsprung\'s-disease/symptoms-causes/syc-20351556
What can I do to achieve what I want?
This should work, both characters must be escaped into the query:
SELECT * FROM `urls` WHERE text LIKE "%\\\\\'%"

how can I do it? (3 columns) 1 like [duplicate]

This question already has answers here:
Query with multiple likes
(2 answers)
MYSQL query - multiple likes
(1 answer)
Multiple Likes in SQL
(1 answer)
Select Command with Multiple LIKEs
(2 answers)
mysql multiple OR NOT LIKES
(2 answers)
Closed 5 years ago.
How can I search in 3 columns with LIKE?
the following code gives an error
$sql .= " AND (Genre, Genre2, Genre3) like '%$s2%'";
full sql;
SELECT * FROM films where Title_ing like '%$s1%' OR Title_de like '%$s1%' AND (Genre like '%$s2%' OR Genre2 '%$s2%' OR Genre3 '%$s2%') AND imdbRating like '$s3%'
You need to use OR
AND (Genre like '%$genre%' OR Genre2 '%$genre%' OR Genre3 '%$genre%');

how to get blob size in mysql [duplicate]

This question already has answers here:
Calculating total data size of BLOB column in a table
(4 answers)
Closed 8 years ago.
i have a table where i am saving images as blob
now the issue is, how can i get the size of the blob in each tuple.
is there any query to do so?
Try
SELECT OCTET_LENGTH(blob_content) FROM test_blob WHERE id = 1
Use SELECT OCTET_LENGTH(blob_tablename) FROM...

Categories