473,809 Members | 2,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving text in a string within a row

I have list of titles in a database, many of which begin with "the..."

Is there an sql statement to move the "the" from the beginning of the column
and place it at the end

eg "The Big Blue House" would become "Big Blue House, The"

"The Cat and Dog" would become "Cat and Dog, The"

Many Thanks

Craig
Jul 20 '05 #1
5 1301
Craig Keightley wrote:
eg "The Big Blue House" would become "Big Blue House, The"
"The Cat and Dog" would become "Cat and Dog, The"


SELECT IF(POSITION("th e" IN title) > 0,
CONCAT(SUBSTRIN G(title FROM 5), ", The"),
title) AS title_alphabeti zable
FROM . . .

I tried this with a quick table in my test database, and it seems to
work. POSITION() is even case-insensitive.

Regards,
Bill K.
Jul 20 '05 #2
Bill Karwin wrote:
SELECT IF(POSITION("th e" IN title) > 0,


Oops! Perhaps that string should be "the " (with a space within the
quotes), so you don't get results like "lma and Louise, The".

Regards,
Bill K.
Jul 20 '05 #3
thanks i'll give it a go
craig

"Bill Karwin" <bi**@karwin.co m> wrote in message
news:ce******** @enews1.newsguy .com...
Bill Karwin wrote:
SELECT IF(POSITION("th e" IN title) > 0,


Oops! Perhaps that string should be "the " (with a space within the
quotes), so you don't get results like "lma and Louise, The".

Regards,
Bill K.

Jul 20 '05 #4
That works as a select statement but how do i update the records, it only
displays the results
"Craig Keightley" <do**@spam.me > wrote in message
news:41******** **************@ news-text.dial.pipex .com...
thanks i'll give it a go
craig

"Bill Karwin" <bi**@karwin.co m> wrote in message
news:ce******** @enews1.newsguy .com...
Bill Karwin wrote:
SELECT IF(POSITION("th e" IN title) > 0,


Oops! Perhaps that string should be "the " (with a space within the
quotes), so you don't get results like "lma and Louise, The".

Regards,
Bill K.


Jul 20 '05 #5
Fixed it
update tablename set fieldname = concat(substr(. ..), ', the') where
fieldname like 'the %'

"Craig Keightley" <do**@spam.me > wrote in message
news:41******** **************@ news-text.dial.pipex .com...
That works as a select statement but how do i update the records, it only
displays the results
"Craig Keightley" <do**@spam.me > wrote in message
news:41******** **************@ news-text.dial.pipex .com...
thanks i'll give it a go
craig

"Bill Karwin" <bi**@karwin.co m> wrote in message
news:ce******** @enews1.newsguy .com...
Bill Karwin wrote:
> SELECT IF(POSITION("th e" IN title) > 0,

Oops! Perhaps that string should be "the " (with a space within the
quotes), so you don't get results like "lma and Louise, The".

Regards,
Bill K.



Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1423
by: Ryan Spencer | last post by:
Hello Again Everyone, As previously aforementioned in my post 'Moving around in a string', I've finally found my result to the pig_latin approach. import string choice = raw_input("Would you like pig latin (p) or ubby dubby (u) translation? ")
5
1263
by: Craig Keightley | last post by:
I have list of titles in a database, many of which begin with "the..." Is there an sql statement to move the "the" from the beginning of the column and place it at the end eg "The Big Blue House" would become "Big Blue House, The" "The Cat and Dog" would become "Cat and Dog, The" Many Thanks
1
2743
by: Kirok | last post by:
Hey Everyone, Thanks for reading, heres what I'm trying to do I have an array of say 10 items each item contains the text / description for a room. Now I would like to create a class (lets call it BookSection) this class will display the text for the current room the user is in and then have links to other rooms (left, right, east, west, etc) then dependant upon the choice made by the user will move to the new room and display the text
6
4920
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox are not data bound (they just use the built in collection property of the ComboBox), and they are all set to use the DropDownList style. When moving from record to record via a BindingNavigator or a DataGridView (in master/detail format), the text...
2
9381
by: Diogo Alves - Software Developer | last post by:
Greetings I would like to knowhow can I put a sliding panel... I've done this: if (panel1.Width < 300) { while (panel1.Width < 300) { panel1.Width = panel1.Width + 40;
1
11072
by: mmalloc | last post by:
I have the following code to move some text with javascript that works both on ie and ff. I can't make it XHTML compatble. If i remove the doctype info it will work. I'm sorry to bother with such simple question but is there someone to see where am i wrong? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
0
4644
by: SuzK | last post by:
I am trying to calculate in VBA in Access 2002 a moving average and update a table with the calculations. Fields in my WeeklyData table are Week Ending (date) ItemNbr (double) Sales Dollars (double) Sales Units (double) Promo (Text) -- is null or "X" AvgWklyDollars (double) AvgWklyUnits (double) I have a vba module which I thought would work, but it doesn't. I think the problem is an embedded SQL Totals Top 8 query, which doesn't...
3
4688
by: Avi | last post by:
Hi all, I have a web page with Multiline TextBox. Every 3 seconds I refresh the page and display all received messages in this TextBox. When the TextBox is updated (The Text property is set). The vertical scrollbar is flickering (moving up and down and the scrollbar "square" is starting big and shrinks when the TextBox is filled). Please note that every refresh more data is added to the TextBox, and nothing is taken out (Appending...
5
2707
by: adarshyam | last post by:
Hi friends, I have an interesting problem in vb.net. And I am struggling to get a solution for this..m trying for the past 3days.. It’s to calculate moving average for the inputs given by the user.. The following are the steps.. 1, get 2user inputs in textbox(1st input is number is periods, 2nd is moving range) 2, after getting both the user inputs, the user will click on an input button which must dynamically generate rows for the number...
0
9601
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5687
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.