473,386 Members | 1,652 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

How to query Boolean columns to return ones with value 0?

Hi,

I want to query the table below as to return the titles of the column where the intersection of SessionId and Roomx is 0.The type of the Room is TINYINT - which in mysql represents BOOLEAN

Below is the table:

Expand|Select|Wrap|Line Numbers
  1. SessionId    Room1    Room2    Room3
  2.         1          0        1        0  
  3.         2          1        0        1
  4.  
For the above table for example for SessionId 1 , query should return Room1 and Room3
Help will be much appreciated.
Thanks.
Feb 8 '11 #1
4 2717
Rabbit
12,516 Expert Mod 8TB
You'll need to unpivot the data if MySQL supports that functionality. If not, you'll need to unpivot manually with a union query. Once the data is normalized, you can make the query.
Feb 8 '11 #2
Ok.Thanks.
Mysql does not support PIVOT/UNPIVOT.Therefore i need to do a manual pivot using a union query you said?
This means creating a pivot table?
How should i go about this , for the table above ?
Feb 8 '11 #3
Rabbit
12,516 Expert Mod 8TB
You don't create a pivot table. You can just use a query to unpivot each column. Something like
Expand|Select|Wrap|Line Numbers
  1. SELECT SessionID, 'Room1' AS RoomID, Room1 AS columnName
  2. FROM Table1
  3.  
  4. UNION
  5.  
  6. SELECT SessionID, 'Room2' AS RoomID, Room2 AS columnName
  7. FROM Table1
  8.  
  9. etc.
Feb 8 '11 #4
dgreenhouse
250 Expert 100+
See my posting here:
http://bytes.com/topic/mysql/answers...olumns-command
Feb 28 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Phil Powell | last post by:
My first time working with a PHP class, and after 6 hours of working out the kinks I am unable to return a value from the class, so now I appeal to the general audience what on earth did I do wrong...
3
by: Federico Caselli | last post by:
I'm using visual basic.net, I need to take in input a string containing an expression and return the value, example: "14=14" must return true "14+14" must return 28 "8<4" must return false
6
by: Bruce W.1 | last post by:
The intent of my web service is an RSS feed from a blog. Originally I used a StringBuilder to make the XML and returned a string from the webmethod. But this doesn't display properly in IE. So...
1
by: Ken | last post by:
I wrote a function to use in queries that takes a date and adds or subtracts a certain length time and then returns the new value. There are times when my function needs to return Null values. ...
5
by: Sam | last post by:
Hi, How, if possible, can I return a value from an event ? In : Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click btnSave_Click and...
25
by: guy | last post by:
i have inherited the following migrated vb6 code (vb2005) but i DONT get the "not all paths return a value" squiggly - is this a 'feature' of on error goto? Private Function CreateFolder(ByVal...
4
by: banderson | last post by:
Hello amazing vba writers, I am trying to make a combo box return a value based on a combo box selection. I have tried a number of the codes posted here and am still having problems. I think it is...
2
by: Ken Jones | last post by:
Table URL_3 consist of the following 2 columns of information being Record No and URL No URL 1 http:/publishing/45/100006_f.SAL_Local.html 2 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...

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.