SQL Recipes
A FREE cookbook for SQL queries and examples
Register FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 07-09-2007, 06:59 PM
David
 
Posts: n/a
Arrow ANY dialect question:

Write a Command to Find Blank Cells...


I've worked mostly in Visual Basic and simple .html and was wondering if there was an easy method to perform the following operation:

1. Find all blank cells in "Pedigree" column
2. Once blank cell is found, insert the corresponding information from column "MgPedigree" (the information corresponds based on a second column in the table which must be identical to a corresponding column in an exterior table, from which the MgPedigree is coming)
3. List all the information found in a query

Here's what I have so far, I realize that many of these commands do not exist in .sql...wondering if anyone knows of a nice suitable replacement for my beloved "IF" command:

SELECT [Pedigree] FROM [TD Inventory Data]
WHERE [Pedigree] = NULL


INSERT [MgPedigree] FROM [TD2 Tree Data Erase Later]
IF "corresponding" [Accession] = "corresponding" [MgAccession] ...

DISPLAY [Accession]

Thanks in advance!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 07-09-2007, 08:22 PM
Dimitar
 
Posts: n/a
Default ANY answer. Re: Write a Command to Find Blank Cells...

David,

Here is a simple select that reflects my understanding of the task:
SELECT
 case when pedigree IS NOT NULL then pedigree
 else mypedigree end AS 'pedigree',
 accession
FROM
 (
  SELECT
   pedigree,
   accession,
   mypedigree
  FROM
   td LEFT JOIN td1 ON td.accession=td1.myaccession
 ) AS t;


(1) What is the relation between 'accession' and 'myaccession' fields -- 1 to Many, M:1, or M:M?
(2) What if there are records in the first table (TD) that do not have corresponding records in the second table (TD1)? For example, TD.accession = 3, but there is no corresponding TD1.myaccession = 3. And if there are records in TD1 that do not have pairs in TD?
(3) The above statement achieves what you want (I think) by combining data from the two tables in the result, without the need to insert data from one table to another.

Hope this helps.

Dimitar
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-10-2007, 01:47 PM
Unregistered
 
Posts: n/a
Default ANY answer. Re: Write a Command to Find Blank Cells...

Thanks very much.

I seem to be having a operator error, apparently produced by the 'case when' command. I am working in Access by the way.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-13-2007, 05:47 PM
Dimitar
 
Posts: n/a
Default ANY answer. Re: Write a Command to Find Blank Cells...

Sorry, I am not a MS Access user. The statement itself should work on most SQL 92 engines, but obviously not in Access.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 09:11 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8