mysql

MySQL - limit from two connected tables

2 tables: name id | title and content name | title One name has several contents. name.id ~ content.name I need to get 3 names with all theirs content. SELECT name.title, content.title FROM name LEFT JOIN content ON name.id = content.name LIMIT 3 result in 3 contents, not names Is it possible to do this with one query?...

Using the MySql ASP.NET membership provider with existing users

I have been tasked with migrating an existing mature ASP.NET 2.0 web site to NHibernate, Mono and MySQL or postgres. I am somewhat confused as how the membership provider salts the passwords. If I make the switch and use the MySQL membership provider (outlined in this question) or AspSqlProvider, will the existing users be able to logi...

Drupal - db_fetch_array returns NULL for every row

I'm using Drupal's db_fetch_array to fetch rows from my db_query. However, every row returned is equal to NULL. Typing the query into PHP myadmin works, so I have no idea whats going on. db_num_rows returns the number of rows as well. Here is the code: if(count($rebuild_ids)) { $ids=implode(",",$rebuild_ids); $type_stmt = "SEL...

NNTP usenet download messages

I would like to download usenet messages to my personal Mysql database, so without using any newsreader. At the moment i'm using IpWorks component for .NET . I've created a simple app in Vb.Net, It works, but it's realy slow... to download and to do the INSERT INTO . Anyone know some better method to "massive" download message and inser...

mysQL Query help regarding find text

Hello, I need to get all rows in which eventname field contains this text (including single quote) 's Birthday I tried this but it is giving error: select * from fab_scheduler where eventname like '%\'s Birthday%' How do i construct such query? Thanks ...

How do I write JPA QL statements that hints to the runtime to use the DEFAULT value ?

I have a table like so: mysql> show create table foo; CREATE TABLE foo ( network bigint NOT NULL, activeDate datetime NULL default '0000-00-00 00:00:00', ... ) In the domain object, FooVO the activeDate member is annotated as Temporal. If I don't set activeDate to a valid Date instance, a new record is inserted with NULLs....

Help for a Sql statement

Hy at all, today is the day of ...question. I've a single table, with a relation master-detail like this: RecordID MasterID Field1 Field2 .... NrDetail 1 0 xxx yyyy 1 2 0 aaaa bbbb 2 3 1 hhhhh ssss 0 4 2 eee sssss 0 5 ...

Higher speed options for executing very large (20 GB) .sql file in MySQL

My firm was delivered a 20+ GB .sql file in reponse to a request for data from the gov't. I don't have many options for getting the data in a different format, so I need options for how to import it in a reasonable amount of time. I'm running it on a high end server (Win 2008 64bit, MySQL 5.1) using Navicat's batch execution tool. It's b...

Integrating Incoming Email Into a php/mysql App

I am looking to create an incoming email daemon switchboard that I can integrate with various remote php/mysql apps. Ideally I want to check the 'to' address to see if it is in a mysql database and if it is, have the email parsed and posted via CURL to a target destination as well as have attachments saved somewhere locally. I will like...

PreparedStatement throws MySQLSyntaxErrorException

I have the following Java code: String query = "Select 1 from myTable where name = ? and age = ?"; PreparedStatement stmt = conn.prepareStatement(query); stmt.setString(1, name); stmt.setInt(2, age); ResultSet rs = stmt.executeQuery(); Whenever I run the above code, it throws an exception on line 2 (where the PreparedStatement is decl...

How do I generate site map from MySQL database

Hi all I am new to Php and working on a project which needs to generate sitemaps from URLS which stored in MySQL database. how can I do this?? Is there any one have any idea?? site maps can be in php extension too and only requirement is list of sites display in each page ...

Join Query Help

Hello, The query below works well. It pulls data from two MySQL tables, "submission" and "login." I would like to also pull data from a third table called "comment" in the same database. The table "comment" has the following fields: commentid, loginid, submissionid, comment, datecommented Two of the fields in the table "login" a...

PHP & MySQL pagination display problem.

I asked a similar question like this yesterday but after waiting for ever I figured out part of the problem but now I'm stuck again I'm trying to display ... when the search results are to long because my pagination links will keep on displaying and will not stop until every link is displayed on the page. For example I'm trying to achi...

Help with MySQL (.sql) and Shell Script

How do I call the following in a .sql file? mysql -u username -h serverip db -e "select a, b, c, d from mytable" > '/home/dump/result.txt'; I will then have to convert the tab separated file to csv for which I want to use sed. Is there a way to do it all in one line? (append sed command to convert the .txt file to csv) How to use ...

How do I use a MySQL subquery to count the number of rows in a foreign table?

I have two tables, users and reports. Each user has no, one, or multiple reports associated with it, and the reports table has a user_id field. I have the following query, and I need to add to each row a count of how many reports the user has: SELECT * FROM users LIMIT 1, 10 Do I need to use a subquery, and if so, how can I use it ef...

Add several fields to MySQL Database

I am fairly new to building sites with PHP and MySQL but am trying to achieve the following: During an online enrollment process, a promoter is able to enroll up to 20 'fighters' for medical testing services. Each fighter's information is stored in SESSION as $_SESSION['FnumAttr'] where num is the number and Attr is the attribute being ...

Indexing datetime in MySQL

What is the best way to index a datetime in MySQL? Which method is faster: Store the datetime as a double (via unix timestamp) Store the datetime as a datetime The application generating the timestamp data can output either format. Unfortunately, datetime will be a key for this particular data structure so speed will matter. Also,...

Mysql INSERT statement saving some queries but not others

Here is a set of queries that are being executed all in succession (via a foreach php loop). Following the query is the mysql_insert_id, supposedly showing a successful query. INSERT INTO item_relationship (table1, item1_ID, table2, item2_ID, notes) VALUES ('df_dimension','2','df_dimension','1',''): inserted ID: 123 INSERT INTO ite...

How does the where clause in MySQL work ?

I have a doubt. Assume R and S are 2 relations with attributes A and B respectively . If I have a query Select * From R, S Where R.A = S.B Does this work like a double For Loop in say c or c++ For( i=0; i<n; i++) For( j=0; j<n; j++) if (i == j) //DO some work ...

How do I select distinct rows where a column may have a number of the same values but all their 2nd columns have the same value?

I have a table in the form: test_name | test_result ----------------------- test1 | pass test2 | fail test1 | pass test1 | pass test2 | pass test1 | pass test3 | pass test3 | fail test3 | pass As you can see all test1's pass while test2's and test3's have both passes and fails. ...