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 6575971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:27:10+00:00 2026-05-25T15:27:10+00:00

You have 2 columns Link , Status in the db MyDatabase . Link column

  • 0

You have 2 columns Link, Status in the db MyDatabase.
Link column contains strings, the values look like http://anysite.com/some/more/symbols?... (varchar(256)).
Status values could be NULL (by default) or 0 or 1 or 2. (int(2)).

How to update column Status so that NULL will be replaced by 0 or 1 or 2 using this rules:

0) we split Link column by groups depending on its value (links that follow to the same web-site, even to the different pages, are in the same group)

1) for all links in the same group we replace NULL with 0, if Status 0 is at least for 1 link within that group;
for all links in the same group we replace NULL with 1, if Status 1 is at least for 1 link within that group and there are no zeroes;
for all links in the same group we replace NULL with 2, if Status 2 is at least for 1 link within that group and there are no 0 or 1;
So that 0 has a highest priority, then goes 1, then 2, and NULL has the lowest priority.

2) if all Status are NULL for 1 group, we do nothing.

As a result, the database MyDatabase

Link                                    Status
--------------------------------------  ------
http://stackoverflow.com/question       NULL
http://google.com/?query=AmIPregnant    2
http://stackoverflow.com/question/ask   NULL
http://google.com/?query=weather        NULL
http://google.com/?query=love           1
http://stackoverflow.com/question/abcd  NULL

should become:

Link                                    Status
--------------------------------------  ------
http://stackoverflow.com/question       NULL
http://google.com/?query=AmIPregnant    1
http://stackoverflow.com/question/ask   NULL
http://google.com/?query=weather        1
http://google.com/?query=love           1
http://stackoverflow.com/question/abcd  NULL

All links contain http://, no https://, no ftp:// are in .com and have at least / symbols after .com (this is to simplify the question about this query).

Is it possible to make using just 1 query?

To better understand the question, just guess 1= “I have checked, this web-site contains AT LEAST 1 page in English”, 2= “I have checked, this web-site contains AT LEAST 1 page in French”, NULL(by default) actually means “I visit 0 pages at this web-site”.

The goal is to update the database using just 1 query.

I would guess SELECT Link as currentlink, Status AS currentstatus FROM MyDatabase WHERE Status is NOT NULL could be used to select those values that are not null to update the rest of values, but then I’m stuck.

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-25T15:27:11+00:00Added an answer on May 25, 2026 at 3:27 pm

    why dont you use an UDF (store procedure) to do that programatically?

    Well, you can try to do it with some UPDATE with sub strings and IF/HAVING structures, but that will be more time expensive. The real way to do that is with a temporal table, or a custom cursor to fetch the rows. Maybe, as the last option, you can find a work around script to do that in a schedule time or with a trigger (when something is affected by… event).

    Anyway, please me say it to you, the way that you re looking for is more complex and time expensive that the right way to do it.

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

Sidebar

Related Questions

I have a web page with a grid, and some columns have a link
I'm creating a 'similar items' link table. i have a 2 column table. both
I have data table containing one column as FilePath. FilePath D:\New folder\link.txt D:\New folder\SharepointMigration(Work
I have two columns in Excel, like this: A B 0.5 0.4 0.6 0.59
I have two columns. ColA and ColB contains char(10) with data 20090520 and 20090521.
I have a table of four columns. The data in the first column is
I have to add two columns in a ListView . One column shows different
I have a datagrid with different types of columns, like I have checkboxes, combo
I have a table called ApprovalTasks... Approvals has a status column I also have
Please go to the link http://www.networksolutions.com/whois-search/reedandthomas.com I want to extract only the below part

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.