query

PHP Class Question

Hi all I am trying to build a PHP class to check the username and password in MySql. I am getting "mysql_query(): supplied argument is not a valid MySQL-Link resource in D:\2010Portfolio\football\main.php on line 38" database has errors:" message. When I move my userQuery code out of my Class, it works fine. Only if it is inside my C...

MySQL Query - Alternation of WHERE IN

I have a mySQL query which takes 3-4 minutes to be executed. It is a large database. This query uses WHERE IN to find the rows.. So, is there any alternate query/clause/statement for my this query? (shortened and formatted version below) SELECT r.reg_id, r.first_name, r.last_name, r.email, r.country, e.headline, e.industry, pp.photo FR...

Using PHP to place database rows into an array?

I was just wondering how i would be able to code perform an SQL query and then place each row into a new array, for example, lets say a table looked like the following: $people= mysql_query("SELECT * FROM friends") Output: | ID | Name | Age | --1----tom----32 --2----dan----22 --3----pat----52 --4----nik----32 --5...

Python: How to execute a SQL file or command

Hi, I have this Python script: import sys import getopt import timeit import random import os import re import ibm_db import time from string import maketrans runs=5 queries=50 file = open("results.txt", "a") for r in range(5): print "Run %s\n" % r os.system("python reads.py -r1 -pquery1.sql -q50 -sespec") file.write('END...

How to store data in mysql, to get the fastest performance?

Hey, I'm thinking about it, which of the following two query types would give me the fastest performance for a user messaging module inside my site: The first one i thought about is a multi table setup, which has a connection table, and a main table. The connection table holds the connection between accounts, and the messaging table. I...

JPA entitymanager remove operation is not performant

When I try to do an entityManager.remove(instance) the underlying JPA provider issues a separate delete operation on each of the GroupUser entity. I feel this is not right from a performance perspective, since if a Group has 1000 users there will be 1001 calls issued to delete the entire group and itr groupuser entity. Would it make mor...

SQL Query over three different tables

i got three tables CATS id name ------------------------------ 1 category1 2 category2 3 category3 4 category4 PRODUCT id name ------------------------------ 1 product1 2 product2 ZW-CAT-PRODUCT id_cats id_product ---------------------------...

nested linq-to-sql queries

var result = ( from contact in db.Contacts join user in db.Users on contact.CreatedByUserID equals user.UserID orderby contact.ContactID descending select new ContactListView { ContactID = contact.ContactID, FirstName = contact.FirstName, LastName = contact.LastName...

Query a Hibernate many-to-many association

In Hibernate HQL, how would you query through a many-to-many association. If I have a Company with multiple ProductLines and other companies can offer these same product lines, I have a Company entity, a ProductLine entity and an association table CompanyProductLine. In SQL, I can get what I need like this: select * from company c wh...

Nhibernate: using Expression

Hello, Using nHibernate, I would like to query on an integer datatype, but its always returning the exact match. How could I write an expression that returns a list starting with the number entered? right now I am using it as: (clientNum is a long) crit.Add(Expression.Like("ClientNumber", clientNum)); //this always gives me exact mat...

NHibernate Query Analyzer

Hello, Could anyone please describe how to use NHibernate Query Analyzer? I downloaded it and trying to build it but it fails, I am not quite sure how to use it. I am using nHibernate with Sybase and WCF. Any help is greatly appreciated. Thanks ...

SQL Query with computed column

help me please with a query. Assume that we have a table with columns: Transaction StartTime EndTime Now, I need a query with computed column of (value = EndTime-Startime). Actually I need to group Users(Transaction has a FK for Users) and sort them by average time spent for transaction. ...

Saving and retrieving image in SQL database from C# problem

I used this code for inserting records in a person table in my DB System.IO.MemoryStream ms = new System.IO.MemoryStream(); Image img = Image_Box.Image; img.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp); this.personTableAdapter1.Insert(NIC_Box.Text.Trim(), Application_Box.Text.Trim(), ...

How can I use a php array in a mysql search query?

I was going to use the scuttle solution on: http://www.pui.ch/phred/archives/2005/04/tags-database-schemas.html for handling searches on my website. I was wondering how I could take the search input from a user and turn it into a single query. For instance, let's say a user inputted 'blue dogs' in their search query... How could I dyna...

What's wrong with this SQL query?

I have two tables: photographs, and photograph_tags. Photograph_tags contains a column called photograph_id (id in photographs). You can have many tags for one photograph. I have a photograph row related to three tags: boy, stream, and water. However, running the following query returns 0 rows SELECT p.* FROM photographs p, photograph...

how so select similarities in MySQL?

Currently, I am doing a search function. Lets say in my database, I have this data: Keyword1 Keyword2 Keyword3 Keysomething Key and the user entered: "Key" as the keyword to search. This is my current query: Q1: SELECT * FROM data WHERE (data_string LIKE '$key%' OR data_string LIKE '%$key%' OR data_string LIKE '...

How can I use an array within a SQL query

So I'm trying to take a search string (could be any number of words) and turn each value into a list to use in the following IN statement) in addition, I need a count of all these values to use with my having count filter $search_array = explode(" ",$this->search_string); $tag_count = count($search_array); $db = Connect::connect(); $qu...

Specify which row to return on SQLite Group By

I'm faced with a bit of a difficult problem. I store all the versions of all documents in a single table. Each document has a unique id, and the version is stored as an integer which is incremented everytime there is a new version. I need a query that will only select the latest version of each document from the database. While using GR...

Techniques for querying a set of object in-memory in a Java application

Hi All, We have a system which performs a 'coarse search' by invoking an interface on another system which returns a set of Java objects. Once we have received the search results I need to be able to further filter the resulting Java objects based on certain criteria describing the state of the attributes (e.g. from the initial objects ...

SQL Latest photos from contacts (grouped by contact)

Hello, To short version of this question is that I want to accomplish something along the lines of what's visible on Flickr's homepage once you're logged in. It shows the three latest photos of each of your friends sorted by date but grouped by friend. Here's a longer explanation: For example I have 3 friends: John, George and Andrea. ...