473,624 Members | 2,469 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

10 New Member
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 2730
Rabbit
12,516 Recognized Expert Moderator MVP
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
Charles Ndethi
10 New Member
Ok.Thanks.
Mysql does not support PIVOT/UNPIVOT.Therefo re 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 Recognized Expert Moderator MVP
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 Recognized Expert Contributor
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
4520
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 this time? This is the code the retrieves the values: if (($hasRegistered || $hasPreRegistered) && !empty($uplinenumber)) { // CHECK TO SEE IF UPLINE NUMBER IS A VALID NUMBER $regNumberGenerator = new RegNumberGenerator($uplinenumber,...
3
1429
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
3434
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 now I'm trying an XmlTextWriter instead. I whipped-up another webservice based on this: http://www.codeproject.com/aspnet/RSSviaXmlTextWriter.asp?print=true This example isn't set up strictly as a webservice. It seems to output to an aspx...
1
2471
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. Function DateCalc (blah...) As Variant Do Stuff... If Not IsNull(varNewDate) Then DateCalc = varNewDate End If End Function
5
1412
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 btnSave.Click must have the same signature so I can't figure out how to do it.
25
2554
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 sFileName As String) As Boolean On Error GoTo Errors 'Create it if necessary If Directory.Exists(sFileName) = False Then
4
3188
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 because I am trying to return a value from a table that only links with the form through an intermediate table. I am hoping to avoid a subform for this one box if at all possible, because of space limitations. Any guidance would be greatly...
2
1731
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 http:/publishing/45/100006_f.SAL_Area.html I need a substring query that will return the values of Local and Area from column URL of Table URL_3 into an additional column of information. I was looking for the solution, shown below, that tried to delimit the desired...
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7168
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.