Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7094011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:30:39+00:00 2026-05-28T08:30:39+00:00

Description of Problem: I want to read data in a column in my sql

  • 0

Description of Problem:

I want to read data in a column in my sql table and clean its values.
It should essentially only have ‘numbers’ of length 9.
It currently is of varchar(11) and holds values like: A:123456789, 1-2:3456789, 123456789H,A-123456789 etc.

How can I add multiple checks for different values of the table and replace the incorrect values and update my table.

I tried righting a search function for checking if values contained are : , –

SELECT budget, descp
FROM yearlybudget
WHERE CONTAINS(budget, '":" OR "-");

SELECT budget, descp
FROM yearlybudget
WHERE CONTAINS(budget, '":" AND "-");

UPDATE dbo.yearlybudget
SET    budget = replace(budget, '":"', '""')
WHERE CONTAINS(budget, '":");

Above are 3 different SQL statements. Can I merge the “OR” and the “AND” conditions checks in anyway? Also how can I add replace to check all the conditions?

Is it best to do it separately for each condition?

Please advise.
Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:30:39+00:00Added an answer on May 28, 2026 at 8:30 am

    First, these queries don’t do what you think they do. The big problem is that there are two single quotes, which together for a string. So your first two queries are actually checking if the string ":" OR "-"); SELECT budget, descp FROM YearlyBudget WHERE CONTAINS(budget, is present.

    Second, doing ":" OR "-" in a contains will not check for both of those strings. Rather, the strings will be evaluated as numbers and then combined with binary OR. Specifically, they’ll evaluate to 0 and then 0 OR 0 will give you 0, so you’re checking CONTAINS(budget,0).

    Third, your replace is not replacing :, but ":". So, it won’t replace the : character unless it’s surrounded by double quotes.

    Fourth, my googling indicates that MySQL doesn’t have a “CONTAINS” keyword.

    The query you probably want looks more like this:

    UPDATE dbo.yearlybudget
    SET budget = REPLACE(REPLACE(budget,'-',''), ':', '')
    WHERE budget LIKE '%:%' OR budget LIKE '%-%';
    

    The % in a LIKE string means “match any characters here”, so it winds up doing the same thing that CONTAINS does on some other database management systems. So, this query will update the budget column by removing all – and : characters, which I think is what you wanted. If you want to do something different, you should probably say what. For example, if you only want to get a version of the budget column without : or -, then you should use a different query, since this one will actually change the data in the database. Be sure that you want to remove – from the budget column before running this, because that has the potential to turn negative budgets positive, which could be a problem.

    To answer the original question about whether or not you can combine the OR and AND, the answer is probably, but it depends on what you’re trying to do. OR is not exclusive, so A=1 OR B=1 will be true when both A=1 and B=1.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem when want read object with where (double variable) this is my
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
Problem description: Read an xml file, traverse to a particular node (element), if it
I have a problem with the query below in postgres SELECT u.username,l.description,l.ip,SUBSTRING(l.createdate,0,11) as createdate,l.action
Here is the description of problem . I have parent div(allcomments_4) and than inside
When a reader starts to read the function code, he should already have a
I have the read feed working and get back everything I should and it
I have problem with uploading image to SQL database. i have Methods Upload in
Expanding this question on how I learnt to pass from problem description to code
Ok, so here's the full description of the problem I'm having: I am trying

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.