select

Select query in MySQL

Two tables Table1 ID FileName 1 abc 2 abc 3 abc 4 xyz Table2 ID Table1_ID isDeleted 1 1 1 2 2 1 3 3 0 4 4 0 I need to get the count of filename for the isDeleted=1 by passing any ID of table1, i.e for all the values(1,2,3) of ID, i need the count as 2 I tried with the following query S...

use parameter when populating a struct with dataset c#?

Hi! I have a struct in a web service in c#. When I use "Selet * from TABLE1"; in a WebMethod I get a fully populated struct. But when I add a WHERE clause, I get null in response. Why is this? I have searched everywhere for a simple explanation but haven't found one. How can I use a SELECT * FROM TABLE1 WHERE _id=" + id "'"; If I only ...

SQL Select Statement: How to get all values from Table 'M' and any correlating values from Table 'T' or 0 if nothing.

I am trying to create a query within a commercial ERP system that uses Access as its database, E2 Shop System. So it just runs the query through Access. I want the query to tell me "how much time was logged on every machine on a prompted date, even if it is 0". I have figured out how to get it to output how much time is on a machine...

Slow select query with left join is null and limit results

I have the following query that is being logged as a slow query: EXPLAIN EXTENDED SELECT * FROM ( `photo_data` ) LEFT JOIN `deleted_photos` ON `deleted_photos`.`photo_id` = `photo_data`.`photo_id` WHERE `deleted_photos`.`photo_id` IS NULL ORDER BY `upload_date` DESC LIMIT 50 Here's the output of explain: id select_type table type...

How to select 12 rows of a given result set for use in DataGrid/Paging? Need to override Grid default caching.

I have a SQL query that will return over 10,000 rows. Since the client only will view 12 rows at a time, how do I alter my SQL so that I can select just the needed rows? My expectation is that I'll requery the database each time the user clicks on the grid. My solution is based on the demo below, however I'm trying to make this work w...

using results of multi-table SELECT to populate test database? (SQL Server 2005)

I was wondering if there were techniques or tools out there that would let me take a multi-table SELECT statement, complete with inner and outer joins, and determine after running it exactly which rows in each table are required to make the same SELECT return the identical rowset in a mini version of the database? The ideal would be to ...

Get drop down value

How to determine what is selected in the drop down? In Javascript. ...

how to use select result with like in mysql

I need some mysql code that uses a select output in LIKE statement in WHERE. I mean something like this: SELECT id FROM (SELECT id,parent_id FROM units WHERE ptitle like '%(SELECT ptitle FROM units WHERE id='".$id."')%') Thanks for your help. ...

simple_form: how to create a grouped select box?

I'm using simple_form gem for creating Rails forms. http://github.com/plataformatec/simple_form All is great, except how do I create a grouped select box? Can't find it in the docs or by google-ing. ...

Many-to-Many self-referencing select sql query

I have a simple table (MySQL) set up for relationships between two users. [User1Id] [User2Id] 10 15 14 10 10 13 But, I can't figure out how to do a SELECT in such a way that I can grab the opposite UserId of the user being requested. So, if I wanted to get all relations for the user with an ID of 10, it wo...

MySQL: List instructors (names) who taught a section of CS160 and a section of CS340 in 99F term.

The schema is as follows: Student(Snum, Sname) Course(Cnum, Cname) Professor(Pnum,Pname, Dept, Office) Class(Cnum, Term, Section, Instructor) How can I join the two selects below to get Instructors who taught both CS160 and CS340? SELECT DISTINCT Instructor FROM class WHERE Term = "99F" AND Cnum = "CS160" SELECT DISTINCT Instructor F...

select vs poll vs epoll

Iam designing a new server which needs to support thousands( somewhere between 100,000 sessions) of udp connections. What is the best polling method to use for socket FD's. I have read that epoll is better than select/poll. Any input or suggestions on which one to use. Thanks. ...

MySQL: Complex question with schema given

Here is the schema: Student(Snum, Sname) Course(Cnum, Cname) Prerequisite(Cnum, Prereq) Professor(Pnum,Pname, Dept, Office) Enrollment(Snum, Cnum, Term, Section, Mark) Schedule(Cnum, Term, Section, Days, Time, Room) Class(Cnum, Term, Section, Instructor) The full question is: Find professors (Pnum, Pname, Dept) who whenever taug...

MySQL: List students (Sname) who enrolled in more than 6 (distinct) classes in a term.

Given the schema: Student(Snum, Sname) Course(Cnum, Cname) Prerequisite(Cnum, Prereq) Professor(Pnum,Pname, Dept, Office) Enrollment(Snum, Cnum, Term, Section, Mark) Schedule(Cnum, Term, Section, Days, Time, Room) Class(Cnum, Term, Section, Instructor) I have come up with: SELECT * FROM Student s HAVING MIN( SELECT COUNT(*) FROM ...

count(*) where cond = val, or count(cond = val)

What is the difference between these two methods? select count(*) from `table` where `column` = 'value'; and select count(`column` = 'value') from `table`; To me they seem to do the same thing; I assume this is not the case for the database. Does one method leverage indexes better than the other? In this case I use MySQL but a gen...

SQL Server create a full field select fast

When writing a statement select * from tableName you get all the fields, however I want to get all the fields in the statement for better code, is there a tool to do it faster in SQL Server, to get select f1,f2,f3 from tableName which are all the fields in tableName ...

MySQL Query Help

I have the following 5 tables: users(user_id) books(book_id, author_id) source_phrases(source_phrase_id, book_id, phrase) synonym_phrases(synonym_phrase_id, source_phrase_id, reader_id, synonym) synonym_ratings(synonym_ratings_id, synonym_phrase_id, rater_id, rating) I am trying to get a query that will select all the books a user has...

trigger('change') selects the 1st option, which I don't want

I have a select that has several options. No empty option. Before calling the trigger none of the options are selected, after it runs the first option is preselected, and I want that the select to stay as it was, no option selected $("#selProduct").trigger('change'); How to fix this? I still want to trigger the change, to run the eve...

Socket.select not returning readable sockets in c#

I'm building a server that serves two clients using streamreaders/writers (using networkstreams), using newline symbols to indicate the start/end of a new command. Because readline (and writeline too, but that's not an issue), will block until there actually is a line to read, I use socket.select in order to determine when there is a li...

Get data across the same table

I have table sort of like Name |DateOfEvent|EventType ---------------------------------- Smith |10/1/2005 |New Thomas |1/1/2002 |Updated Johnson |6/1/2002 |New Smith |7/1/2008 |Updated Smith |7/1/2000 |New I want to return rows where the event is say New and the date is before a row with the same name bu...