select

I DISTINCTly hate MySQL (help building a query)

This is staight forward I believe: I have a table with 30,000 rows. When I SELECT DISTINCT 'location' FROM myTable it returns 21,000 rows, about what I'd expect, but it only returns that one column. What I want is to move those to a new table, but the whole row for each match. My best guess is something like SELECT * from (SELECT DIS...

Help with IF THEN breaking when comparing results from MYSQL query.

I'm have a problem with an invite system. The if statement seems to break. It shows the message "Fail" but the UPDATE statement still executes. Why do both the THEN and the ELSE excute? $dbConn = new dbConn(); // Check if POST user_username and user_hash are matching and valid; both are hidden for fields $sql = "SELECT user_username " ...

jquery form select (if exists in $_POST)

Hi all, I'm trying to redo this in jQuery: <script language="JavaScript" type="text/javascript"> var thisIsSelected = '<?php echo $_POST['image']; ?>'; var sel1= document.getElementById('image'); sel1.value = thisIsSelected; </script> But I seem to keep breaking it lol Basically I want jQuery to check if $_POST['image'] exist...

Select Menu, go to url on select with JQuery?

Hey Guys, I have the following html: HTML markup <ul id="test"> <li><a href="http://www.yahoo.com"&gt;yahoo&lt;/a&gt;&lt;/li&gt; <li><a href="http://www.google.com"&gt;Google&lt;/a&gt;&lt;/li&gt; </ul> And some JS code: JQuery/JavaScript Code $('ul#test').each(function() { var select=$(document.createElement('select'))....

Modify Return Value of SELECT-Statement (TSQL) [Optimizing query]

Problem: A Database collumn has a Tristate (0,1,2). Each of the values are used serversidely. The Clientcode (which cant be changed anymore) is only able to understand '0,1'. In the Clients view '1' is identic with '2'. So I want to change the SQL Query in the Database to return '1', if the specific value is > 0. My current Solution ...

SQL Server - How to switch between 2 possible SELECT statements

I would like to use a parameter in my mssql stored procedures to switch between a small and a detailed result (for maintainability, performance and network load reasons). If parameter is set to 1 i get all columns, else only the one or two most important. In a very limited way it works like this: ALTER PROCEDURE [dbo].[GetAllUsers] @d...

How to coerce type of ActiveRecord attribute returned by :select phrase on joined table?

Having trouble with AR 2.3.5, e.g.: users = User.all( :select => "u.id, c.user_id", :from => "users u, connections c", :conditions => ... ) Returns, e.g.: => [#<User id: 1000>] >> users.first.attributes => {"id"=>1000, "user_id"=>"1000"} Note that AR returns the id of the model searched as numeric but the selected user_id of...

Is it possible for select lists in HTML to have a horizontal scrollbar?

If you have an HTML <select multiple> of a certain width and height (set in CSS), if there are more values then you can possibly fit in that height, then the browser adds a vertical scroll bar. Now if the text is longer than the available width, is it possible to instruct the browser to add a horizontal scrollbar? ...

count total records after groupBy select

Hello, I have a mysql select query that has a groupBy. I want to count all the records after the group by statement. Is there a way for this directly from mysql ? thanks. ...

Jquery Show Fields depending on Select Menu value but on page load

Hello, This question refers to the question http://stackoverflow.com/questions/835259/jquery-show-hide-fields-depening-on-select-value <select id="viewSelector"> <option value="0">-- Select a View --</option> <option value="view1">view1</option> <option value="view2">view2</option> <option value="view3">view3</option...

DocumentFragment not appending in IE

I have a select list which, when changed, pulls data via ajax and dynamically creates select lists. Then based on the data used to create the select lists (a type), I pull more data via ajax if i don't have it already and create the options for the select list and store them in a fragment. Then I append that fragment to the select list...

In SQL, why is "select *, count(*) from sentGifts group by whenSent;" ok, but when "*" and "count(*)" is switched position, then it gives an error?

In SQL, using the table: mysql> select * from sentGifts; +--------+------------+--------+------+---------------------+--------+ | sentID | whenSent | fromID | toID | trytryWhen | giftID | +--------+------------+--------+------+---------------------+--------+ | 1 | 2010-04-24 | 123 | 456 | 2010-04-24 01:52:20 | 10...

PHP DELETE immediately after select

I have a PHP server script that SELECTs some data from a MySQL database. As soon as I have the result from mysql_query and mysql_fetch_assoc stored in my own local variables, I want to delete the row I just selected. The problem with this approach is that it seems that PHP has done pass-by-reference to my local variables instead of pas...

select always returns -1 while trying to read from socket and stdin

Hello I have the following code implemented on C++(Linux) to check on my listening socket and stdin using select. select however keeps returning -1 no matter what I try to do! What's wrong with that code :s I will appreciate any help. Thanks highsock = m_sock; //listening socket memset((char *) &connectlist, 0, sizeof(connectlist)); m...

How to use php variables (arrays) in mysql select statements?

Hi everybody, How do you use a php variable (array) inside a mysql select statement? I am designing an auction site and currently working on a page that lets people view a list of all the current bids for an item. I want to display 3 columns: amountbid - the amount each bidder has bid for the item (held in tblbid) b...

GWT: Select a TreeItem with right click

I'm capturing a right click event to show a context menu. What I haven't been able to figure out, is how to make the right click actually select the TreeItem, prior to showing of context menu. All help is appreciated. private Tree tree = new Tree() { @Override public void onBrowserEvent(Event event) { if (event.getTypeInt()...

How to select non-consecutive options of multiple select using keyboard in IE

Using only keyboard, how can I select non-consecutive options of a multiple select element. On Firefox or Windows explorer, I can simply ctrl+Arrow to move the focus and then space bar to select. But I don't see any way to make it work on IE. Thanks ...

COUNT(*) vs. COUNT(1) vs. COUNT(pk): which is better?

Hello guys, I often find these three variants: SELECT COUNT(*) FROM Foo; SELECT COUNT(1) FROM Foo; SELECT COUNT(PrimaryKey) FROM Foo; As far as I can see, they all do the same thing, and I find myself using the three in my codebase. However, I don't like to do the same thing different ways. To which one should I stick? Is any one of ...

SQl count() help with a select statement

HI im using this code SELECT MACH_NO, COUNT(MACH_NO) AS TOTAL_REPORTS FROM MAINTENANCE_LOG GROUP BY MACH_NO; to retrieve some data which gives MACH_NO TOTAL_REPORTS 1 4 5 2 8 1 7 1 now how can i retrieve only where total reports is bigger than three? I TRIED WHE...

Advantage Database Server ORDER BY behaviour

I'm using ADS v10 beta. I'm trying to numerate ordered resultset. 1) ORDER BY in nested queries. I need to use nested SELECT for some calculations: SELECT Name, Value, ROWNUM() FROM (SELECT * FROM MainTable WHERE Value > 0 ORDER BY Value) a And I'm getting Expected lexical element not found: ) There was a problem parsing the table ...