WHERE COLUMN=1 AND COLUMN=2

I have a table that I need to select ALL values that are submitted, so I can't use COLUMN IN (1,2) as this would return all rows with either 1 or 2. Same goes for using OR.

So how do I transform the impossible query "WHERE COLUMN=1 AND COLUMN=2" into one that actually returns a result?

In this example what I want to return would be all id's that have 1 AND 2 in the column in question, just to be be clear.

Cheers!

/Eskil

 

0
utlandsfantomenno1
12/15/2007 10:10:03 PM
asp.net.sql-datasource 29906 articles. 0 followers. Follow

5 Replies
847 Views

Similar Articles

[PageSpeed] 37

A column can only have ONE value. It can't be both 1 and 2. 


-- "Mark As Answer" if my reply helped you --
0
gunteman
12/15/2007 10:53:28 PM

Yes, you're correct.

What I was asking for was this:

"So how do I transform the impossible query "WHERE COLUMN=1 AND COLUMN=2" into one that actually returns a result?", I'll explain further:

What I want to do is return all rows WHERE the same ID (x) has values 1 AND 2 in the column.

Cheers!

/Eskil

0
utlandsfantomenno1
12/15/2007 11:48:51 PM

 Hi

Is this statememt satisifes ur requirement.Plz Check out. I think u posted this thread. am i right.

insert into x(i) select i from x where i=1 or i=2 

Thank u

Baba

Please remember to click "Mark as Answer" on this post if it helped you. 


Thank u

Baba

Please remember to click "Mark as Answer" on this post if it helped you.
0
srijaya_ramaraju
12/16/2007 11:12:50 AM

Ok,

SELECT ... FROM thetable t1
WHERE x IN (

SELECT x FROM thetable t2
INNER JOIN thetable t3 ON t2.x=t3.x
WHERE t2.COLUMN=1 AND t3.COLUMN=2
 )

 

is one way of doing it.  


-- "Mark As Answer" if my reply helped you --
0
gunteman
12/16/2007 11:56:30 AM

Thanks!

0
utlandsfantomenno1
12/16/2007 3:40:47 PM
Reply:

Similar Artilces:

separate 1 column of retreived sql data into 2 evenly spaced columns
I have a DB call that pulls back a set of records containing X number of First Names.  Instead of listing them in one single row, I'd like to separate the records into 2 rows for a better visual interfeace.What's the best way to do this?I couldn't figure out how to do it with a Datagrid.Thanks in advance! Use a DataList. It lets you define how many columns of data you want to list....

VB.NET 1.1 Searching through DataList Column by Column
Hi,I am trying to search through a DataList column by column.  I am doing this so that if each cell within that sector is empty then I will hide that column.  I have implemented a quick function in order to do this, however, it is searching through the datalist row by row.  Below is my code, with explanations of what the code is trying to do.  I think the problem is to do with the String sector.  Is there anyway that I can change the sector string so that it will iterate through the table (dataset) column by column.Code:Dim myData As Data.DataSet = dbAccess.getChildr...

How to divide 1 GridView Row with 1 column in 2 Rows with 5 columns?
Hi; I have a GridView with 10 rows and 1 column. How can I do to this GridView show the same data, but with 2 rows and 5 columns? In classic ASP, I made it this way: While (NOT rsFotos.EOF) if i mod 5 = 0 then Response.Write "</tr><tr>" end if ... Someone can help? :)  You have to use a custom template and lay the table out the way you want, either dropping controls in the template or creating a custom ITemplate that takes care of it for you. http://professionalaspnet.com/archive/2006/06/15/Useing-ITemplate-in-the-Data-Controls.aspxChris L...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

Query split column in 2 columns in SQL
I like to push 1 column into 2 different columns just to show it on the screen. So no import in another table ore something like that. I have a table like this: Select Name from Cars; Result: Col1 BMWMercedesFordAudi But i like to make a query so it is displayed like this: Col1                Col2 BMW               FordMercedes         Audi So i can bound a table directly to that column!Is this p...

[help]Combine 2 column into 1 column
I want to combine 2 column (Column A from Table A and Column B from Table B) into new Column in new Table. So, the new column will contains value of Column A and Column B. For example; Column A contains A, B, C, D, E                     Column B contains 1,2,3,4,5 New Column will contains A,B,C,D,E,1,2,3,4,5 Did anybody know how to do that???? Thanks in advance... You didnt specify WHERE your creating this table.  Do you need to permanently do it, or are you just needing to combine them...

1 non-scrolling column in a 2-column table
I've got a page which consists of 2 columns. Column 1 contains the main contents of the page, and the other column displays an advisement image. I want the browser's vertical scrollbar to only affect column 1 so the advertisement is on display at all times. I've tried the basic overflow settings in CSS but to no success. An example of what I want to achieve is similar to the side advertisements (skin) on TV.com. Any ideas would be greatly appreciated. Thanks. try like this take a table with 2 <td>'s. In the first <td> put ur ur content inside the ...

FooterTemplate wants to start on Column 2 not Column 1
Hi all, I don't have a lot of experience using the FooterTemplate in the Gridview (used it once to insert/add new records).  This problem seems awkward and I'm confident I'm overlooking something simple.  Basically, no matter what I do here, the text in the FooterTemplate starts in column 2.  Below is a sample of my code.  The commented out lines are what I originally had before I tried defining templates hoping that would resolve the issue but it didn't.  I also added Text for the FooterTemplate columns for those columns that I'm not displaying....

When is a column not a column?
I have several extremely similar datawindows that I have to maintain that go against the same table. Recently, I had to add a column to that table, and also add the column to ALL of these datawindows that go against this table. I added the column to the first datawindow, set up the edit control style, etc. I then did a copy/paste of the columns edit control to the remaining dw's (of course remembering to first add the column in SQL). Everything (update props, column specs, column props) seems to indicate that the pasted column is linked to the column I selected, HOWEVER, when I...

Counting Distinct records of column 1 with a certain value in column 2
Ok, so I need to count the Distinct records from column 1 in which there is not a true value in any of the records for that distinct column 1 number. Here is a short example of my records:dbo_dbWafer_Slicing dbo_dbWafer_Slicing WaferID SawDate SawRunNumber    Pass 03-157.05     1/8/2008 9:54:00 AM     03-157 0 03-157.03 1/8/2008 9:53:00 AM     03-157 -1 03-157.04 1/8/2008 9:53:00 AM     03-157 0 03-157.02 1/8/2008 9:52:00 AM  &...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links http://en.wikipedia.org/wiki/.NET_Framework http://blogs.msdn.com/mohammadakif/archive/2006/12/03/net-3-0-different-versions-of-the-net-framework.aspx http://www.codeproject.com/aspnet/ComparisonASP1xASP20.aspAshok Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

is it possible to turn 1 column,many rows into one row,many columns in sql ?
 Hi AllI have the following query:Select CategoryName From Category Where CategoryId In(Select SkillId From SpecialitySkills Where CopywriterId = 13) It gives me the correct results but not in the form that i want, i would like it to be in one row, many columns. its in 1 column, many rows.Any ideas?  You must be talking about displaying it on a web page? Just create a loop that runs through the rows of the data that is returned then just make html table:dim tablestring as string = "<table><tr>" for i as integer = 0 to dt.rows.count - 1 tablestring += &...

is it possible to merge 2 columns into 1 in SQL server
Hi..     is it possible to merge 2 columns into 1 to hold data like this... When the user imports the file in particular file they will be ACT_ID1  Tot_ACT1   ACT_ID2  TOT_ACT2 ...... until 15  BB            1245.45    CT              some amount  .....  The 2 letter character may change prob for each file.. at leat i know of somethem may change So while i transfer the data to the pro...

Why 2 <td> columns in Design tab are displayed as 1 column only in a browser presentation?
I have coded a Table with 1 <tr> and 2 <td> to read fildes from 2 folders.The Design tab did show coding 1 and coding 2 as 2 cells/columns side by side in one row of a table.  However, the browser presentation showed the files ofthe 2nd folders directly under the files of the 1st folder.  Why the browser presentation showed only one coulmn while the Design tabshowed 2 columns?  What might be the reasons for this mistake? TIA,Jeffrey      Please post your HTML.Please remember to "mark as answered" posts that ...

Web resources about - WHERE COLUMN=1 AND COLUMN=2 - asp.net.sql-datasource

Resources last updated: 1/15/2016 5:02:42 AM