Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    MYSQL




Packing Needed For MySQL


I am still playing around with databases. So here it goes:

Is packing needed for MySQL (5.0)?

I have a new DB, which already is 178 MB. Will that continue to grow,
when I add and delete data? Does it reclaim freed space and deleted
rows?

If not, is there a (automated) way to pack tables using SQL or
something simple, which I can call from my app?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Packing MySQL 4.0.13 Along With Our Product...
We are building Applications Manager product which monitors servers (Application servers,web server,..), DB servers, Port monitoring, URL monitoring and much more...

For this at the back-end we are planning to use MySQL DB with versions greater than 4.0.13.

We don't want to force the users to install MySQL 4.0.13 for trying / running our product, also we don't want users to uninstall older versions (lesser than 4.0.13) of MySQL already installed in their machines.

For windows we are packing MySQL (all the data dir, binaries) along with our product.
We like to do the same for linux version also. Even if the older version is running, we will start MySQL 4.0.13 (bundling with our product) in a different PORT, so
in no case it doesn't disturbs or interrupts the version that is already installed/running in their machines.

Has anyone tried similar to this by packing MySQL, if so kindly help us in resolving any discripencies you faced.

Packing Database
I have MySQL on W2K, with a DB where I store date for app. one month,
then I delete them.

How can I pack the database, so I get a smaller file?
(currently 1 GB, was 740 MB a few days ago, even there is less data
now).

I still login as root - I could not find a way to login to my DB using
my own username - probably simple -

Packing Tables
How do I "pack" a table to get rid of empty rows.

MYSQL Help Needed
I am having troubles trying to create my first table in mysql

I am using version 5.0

I have entered the code below in mysql:

mysql>CREATE TABLE table_name (
-> column_1_name column_1_type column_1_details,
-> column_2_name column_2_type column_2_details,
-> ...
->);

and i get the following error:

ERROR 1064 (42000): You have an error in your SQL syntax;check the manual that corresponds to your Mysql server version for the right syntax to use near 'column_1_type column_1_details,column_2_name column_2_type column_2_details,' at line 2

MySQL Join Needed
I'm pretty new to MySQL and I don't really get the whole join thing, although I understand the theory behind it I have problems when putting it into practice. Basically I'm using PHP with MySQL back end and I've got two tables:

TEST
QUESTION

The primary key of Test is "testno" which is an auto_increment and question has "testno" as a foreign key, so I need a join that will insert the value of "testno" into question when ever a record is entered into TEST based on the "testname" which the user enters into a form.

Let me try and clarify:

$testname = $_POST['testname'];
sql="INSERT into question test.testno where testname = '$testname'";

Obviously this will not work but what I need in effect is a query which carries out this function.

Needed Help With Uninstalling MySQL 5 On Mac/Unix
I have MySQL 5 on my Mac 10.4 and I want to completely uninstall it because I think I have MySQL 4 running on it too. I'm not too sure how to check for this. I'm not the best with administrating a database.

MYSQL Query Speed + Explanations Needed
Sometime I need to delete results set of the some query.
Like
DELETE FROM table WHERE id IN (SELECT id FROM .... JOIN .... JOIN ... WHERE ...)

But when I have a table with 100k+ records it become a big problem. Script just hangs up forever
As I understand, mysql get each id from table `table` and reexamine SELECT?

I tried to create temprary table and filled it with select
like DELETE FROM table WHERE id IN (SELECT id FROM `some_temp_table`)

But its hangs up too...
EXPLAIN do not works for the DELETE ... statement, manual do not helped.
So, how does this query work "on the low level"?
DELETE FROM table WHERE id IN (SELECT id FROM .... JOIN .... JOIN ... WHERE ...)

Any suggestion how can I improve speed for the large tables?

VER VERY VERY Slow MySQL Query HELP URGENTLY NEEDED
I have the following MySQL query, but it is VERY VERY slow and seems to be crashing the server. There are 300,000+ records in the 'tracker' table.

SELECT sites.*, SUM(if(tracker.type='view',1,0)) AS numberOfViews, SUM(if(tracker.type='click',1,0)) AS numberOfClicks, SUM(tracker.revenue) AS totalRevenue FROM sites LEFT JOIN tracker ON tracker.site_id = sites.id GROUP BY sites.id ORDER BY sites.domain_name


Advice Needed Login/registration System With MySQL 5/PHP
I want to setup a login/registration system for my website with MySQL 5 / PHP. Most of the job should be the standard stuff: register form, login form, forgot password form, etc.

Can anyone advice me how to begin ?

Are there any good tutorials which i should use or are there freeware or cheap commercial tools which i should use ? Or maybe you recommend me to an awesome programmer you know who does this job at low cost ?

- a MySQL/PHP Newbie

Does Mysql Store Max Size For Data Type Each Time, Or Only What Is Needed For Specific Data?
If I use MEDIUMTEXT, which (if I understand correctly) has a max size of 65k, does mysql use the entire size each time data is written to that column? I have a text field on my site that users fill in, but more often that not, they don't. However, when they do, it can be 1000 bytes or more. Am I wasting space using MEDIUMTEXT or does mysql only set aside 1000 bytes for that column if the data is only 1000 bytes?

Help Needed With DB Structure
I'm finally get a grip on using databases in my scripts, but I'm still lacking a bit in exactly how best to construct my databases ... so I'm hoping that I might be able to get some help with that here

I currently have a MySQL database with one table called "users." In it will be held the registration information for everyone who signs up to the site: username, password, date of registration etc. etc.

Now I want to link that table with another table that will contain information regarding the car that the user drives. This information will be collected from a second form and will contain data such as type, make, year of construction, colour etc. etc.

What's the best way of linking these two tables together in order to help with running searches or scripts in the future? I was planning on inserting the relevant username into the second table as well so that I can run searches across both tables ... but is that the best way of doing it?

Syntax Needed
I have a table consisting of word_nr (key) and example_nr. Now i want to find out how many entries for example_nr are returned where word_nr=x and word_nr=y.
So i made something like:

SELECT count(*)
FROM mytable WHERE word_nr=x and word_nr=y

Query Needed
i have a little problem with figuring out how to make a query for a certain table. The table consists of two columns: word_no and example_no. It is very likely that an entry word_no refers to more than one entries in example_nr. Now i would like to find out how many entries with the same example_nr are there for word_nr x AND word_nr y together.

Timezone Help Needed
I am in Washington State, Pacific timezone. However, our business day runs from 7:00am-7:00am. I have found if I change the system time on the MySQL box to the Japanese Timezone this works in "fooling" the system into thinking 7:00am local time is midnight, the start/end of a business day.. the problem comes when trying to update our intranet website, with the differing timezones..the huge difference in time will not allow updates with our ppl who use front page.
(yes, I know notepad would be a better choice then front page. Not my call)

I have tried unsuccessfully to change the time zone in the [mysqld] & [mysqld_safe] sections of the startup INI file. When I try to force MYsql into the japan time zone the server fails to start and an error message pops up failed to start unexpectedly,

Performance Needed
I have two tables. One for products and one for reviews.
I have setup a detail page which displays the various fields out of the products table and then looks for all reviews in the reviews table which match the products key and display the average. All good so far.
I want to have a page which displays a whole list of the products and show their rating next to them but I'm wondering if making it search the reviews table and calculate the average for 50 products in one go is going to cause a bit of a strain on the server?
Is there another way I can do this, perhaps storing the precalculated average in the products table but how would I go about doing that?

SQL Statement Needed
How would I change in a table every reference to "ren" to "stimpy"?
If a value equaled "renTop" I want it changed to read "stimpyTop".

Two (rather Complex) Problems. Help Needed!
Problem 1

I am developing a system where members of a site can submit graphic designs to a themed pack. Members can then view and rate the submissions from 1-5. This has all been accomplished, but I have encountered one problem.

When listing the themed packs currently in progress, I want to be able to list how many submissions there are, how many of these submissions have a rating above 3.0, and how many of these submissions are above 4.0. I've been able to flawlessly count how many submissions there are without referring to their ratings with this query:

select
p.id as id,
p.title as title,
p.body as body,
p.reltime as reltime,
p.quota as quota,
count(s1.id) as subcount_ns,
from
packs as p
left outer join
submissions as s1
on s1.pack = p.id
where
s1.state > -1
and p.released = 0
group by
s1.pack
order by
p.id asc;
How can I also, within this query, count how many submissions have a rating above 3.0 and count how many submissions have a rating above 4.0? I'm not sure how to do this, since I have already joined the submissions table to the packs table.

The ratings table (sub_ratings) looks like this:



id | subid | userid | rating | time
The subid column refers to the submission's id, the userid column refers to the id of user who rated the submission, and the rating is an integer between 0 and 5.

--------------------------------------------

Problem 2

For the submission system, some users choose to collaborate with other users on one submission. In this case, both of their userids are grouped together in the "creators" column of the submission, being separated by commas. Here is an example:

1,43,65

This would be an example of three users having collaborated on one design.

Is there any possible way that I could, within one mysql query, determine the usernames of each of those users and return it as a column with the requested submission? I'm looking for something along the lines of php's "explode" function, but in mysql.


Thanks in advance for the help that anyone offers.

Help Needed Writing Query
I'm trying to make a query to return 10 sorted values, but I need to calculate the value to sort by, ie its not stored as a field in the table.
So say I had some data like this...

id basicrank time
1 5 40
2 7 33
3 3 55
etc.

I want to sort by (basicrank minus (currenttime - time)), so newer records get some priority, returning highest score first.
My query could then be something like this, given current time of 60.
SELECT id FROM table ORDER BY (basicrank-(60-time)) DESC LIMIT 10

Wordpress Database Help Needed!
I'm trying to import some content into the wp_posts database, which works, but I can't figure out how to make it automatically publish at a later date.

When I publish the imported content manually (eg. edit timestamp and hit publish) it works, but when I try and upload that into the database, it doesn't seem to register.

I'm doing some traveling soon and I don't want the blog to lay dormant! Here's my SQL for an example post:

Quote:

INSERT INTOwp_posts(ID,post_author,post_date,post_date_gmt,post_content,post_title,po st_category,post_excerpt,post_status,comment_status,ping_status,post_password, post_name,to_ping,pinged,post_modified,post_modified_gmt,post_content_filtered ,post_parent,guid,menu_order,post_type,post_mime_type,comment_count`) VALUES
(123, 1, ��-11-21 17:45:39', ��-11-21 23:31:15', 'I AM THE POST CONTENT', 'THIS IS THE POST TITLE', 19, '', 'future', 'open', 'open', '', 'this-is-the-post-slug', '', '', ��-12-01 17:45:39', ��-12-01 23:31:15', '', 0, '', 0, 'post', '', 0);`

So all times are set in the future, and the post_status is "future". Why is it not publishing when the time comes around?

Stored Procedure Needed
I have a table named players with these fields:

playerid {int}
teamid {int}
jersey {int}
playername {varchar(50)}
age {int}
And a table named pitchcounts with these fields:

id {int}
gamenum {int}
playerid {int}
pitchcount {int}
Now, what I need is a stored procedure to return the number of pitches each player pitched in a week where the weekno is passed
and the days rest required and next availability date of the pitcher based on the criteria below:

In-House Ages 13-16 (Babe Ruth)
--------------------------------------------------------
Pitches Days Rest
-------------------------------
0-20 0 Rest
21-40 1 Rest
41-60 2 Rest
61-95 3 Rest

********************************************************
In-House Ages 11 & 12 (Majors-American, National & Continental)
--------------------------------------------------------
Pitches Days Rest
-------------------------------
0-20 0 Rest
21-40 1 Rest
41-60 2 Rest
61-85 3 Rest
No more than 125 pitches in a week. 4 12's can pitch but no more than 240 pitches no matter how many games in a week.

********************************************************
Travel Ages 8, 9, 10, 11 & 12
--------------------------------------------------------
Player can pitch up to three innings in a weekend. Two innings doesn't affect In-House the next day, but prior In-House pitching does apply. If 61 or more pitches on Thurs or Sat no travel that weekend. A travel manager must obtain approval from the In-House manager in order to pitch a player for more than one inning if the in-house team has a game following the travel team on the same day. If pitchers does pitch more than 1 inning in travel, pitcher limited to 60 pitches In-House.
If travel follows In-House on same day, player can pitch in travel if no more than 60 pitches thrown in-house. These rules will be in place until may 1st. We want these rules to be followed in spirit as well as literally. If abuses are found, even if within rules, we will change them after may 1st. Under no circumstances is a player able to be made ineligible for In-House play.

********************************************************
In-House Ages 10 and 9'S in Majors (Majors American, National, Continental)
--------------------------------------------------------
Pitches Days Rest
-------------------------------
0-20 0 Rest
21-40 1 Rest
41-60 2 Rest
61-75 3 Rest
********************************************************
Double A In-House (AA)
--------------------------------------------------------
No more than 40 pitches in a game or 80 for a week.

********************************************************
Additional In-House Notes
--------------------------------------------------------
If a pitcher gets to 85 (75 at age 10) pitches in a game in the middle of a batter, they can finish the batter only. Pitching results must be reported by email to Director within 24 hours of the game by the winning manager. Pitcher can not re-enter to pitch in the same In-House game once removed from the mound. Pitcher receives seven warm-up pitches before their first inning on mound and five every inning thereafter. Warmup pitches no not count toward total counts. Pitches to final batter, if count gets past game or week totals, don't count toward totals. 12 year olds in Continental League can not pitch.

Rest Examples:

if 20 or less on Monday, available on Tuesday
if 21-40 on Monday, available on Wednesday
if 41-60 on Monday, available on Thursday
if 61 or more on Monday, available on Friday

Help Needed To Join Tables.....
I'm starting into mysql these days and I have some tables created

function_detail
+------------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+------------------------+------------------+------+-----+---------+----------------+
| function_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| function_name | varchar(128) | NO | | | |
| function_description | varchar(512) | NO | | | |
| function_image | varchar(256) | NO | | | |
| function_image_caption | varchar(128) | NO | | | |
| function_extras | varchar(64) | NO | | | |
+------------------------+------------------+------+-----+---------+----------------+

option_detail
+----------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+----------------------+------------------+------+-----+---------+----------------+
| option_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| option_name | varchar(64) | NO | | | |
| option_description | varchar(256) | NO | | | |
| option_image | varchar(256) | NO | | | |
| option_image_caption | varchar(128) | NO | | | |
| option_extras | varchar(64) | NO | | | |
+----------------------+------------------+------+-----+---------+----------------+

product_detail
+---------------------------+------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default |Extra |
+---------------------------+------------------+------+-----+---------+----------------+
| product_id | int(10) unsigned | NO | PRI | NULL | auto_increment |
| product_name | varchar(64) | NO | | | |
| product_short_description | varchar(256) | NO | | | |
| product_long_description | varchar(512) | NO | | | |
| product_series | varchar(64) | NO | | | |
| product_heads | varchar(64) | NO | | | |
| product_family | varchar(64) | NO | | | |
| product_category | varchar(64) | NO | | | |
| product_image | varchar(256) | NO | | | |
| product_image_caption | varchar(128) | NO | | | |
| product_catalog | varchar(512) | NO | | | |
| product_status | varchar(64) | NO | | | |
+---------------------------+------------------+------+-----+---------+----------------+

product_function_detail
+-------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+-------+
| product_id | int(10) unsigned | NO | | 0 | |
| function_id | int(10) unsigned | NO | | | |
+-------------+------------------+------+-----+---------+-------+

product_option_detail
+-------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------------+------------------+------+-----+---------+-------+
| product_id | int(10) unsigned | NO | PRI | 0 | |
| function_id | int(10) unsigned | NO | | | |
+-------------+------------------+------+-----+---------+-------+

product_technology_detail
+---------------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+------------------+------+-----+---------+-------+
| product_id | int(10) unsigned | NO | PRI | 0 | |
| technology_id | int(10) unsigned | NO | | | |
+---------------+------------------+------+-----+---------+-------+
these tables are meant for: (let's see if I can explain correctly)
Product Details would contain all the details for a certain products
Function Details would contain all the functions performed by these products.
Technology Detail would contain all the technology embeeded in these products.

Some products may have either the same technology or the same functions (with the same descriptions) but affirmatively not the same product details (description product name & etc).

For Instance
Product A would perform function a,b,c,d and e and would have technology X,Y and Z
product B would perform function f,g and h and would have technology W, Y and Z.
product C would perform function b,c and I and would have technology O,P,Q and X.

How can I link the three tables?
Meaning that product_detail ---> function_detail when the linkage between the two of them resides in product_function_detail?

Here is something I've tryied

SELECT function_id, product_id as producto FROM product_function_detail WHERE product_id = ƈ' ORDER BY function_id asc;

SELECT distinct function_name, function_description, function_detail.function_id
FROM (select function_id, product_id as producto from product_function_detail
WHERE product_id = ƈ' ORDER BY function_id asc)as xref, function_detail
WHERE producto=ƈ'
BUT so far, no luck.

SQL SELECT Statement Help Needed
I have three databases, like so:

1. Visitors: vid(int) | vname(varchar)
2. Events: eid(int) | ename(varchar)
3. Participation: pid(int) | visitor(int from vid) | event(int from eid)

The participation table is a criss cross reference table to associate visitors with events.

Given the vid(from visitor table) how go i query the database to get all the events a given visitor is participating in?

M2M Relational Query Help Needed
I have 3 tables, below are a list of the significant fields in each.

Stories
* story_id
* story_date

Editions
* edition_id
* publication_id

Story_Edition_Jct
* story_id
* edition_id

What I need to do is create a list of all the stories that are newer than 30 days and have not been assigned to a given publication_id, but may or may not have been assigned an edition.

Just to clear that up some more, a publication consists of many editions, so we're looking for stories that may have been published in other publications, but want to restrict them from being republished in a given publication.

The following query is what I've come up with:

Select Statement Needed
The sending page allows the user to choose which search criteria he
wants, so this (and many other) pieces of the select statement may or
may not be present. The statement always starts with

SELECT * from logdata where driver = '$_COOKIE[username]'

If the user has selected them and supplied the proper data for a search,
other elements will be added to the query string. For example, it may
look like

SELECT * from logdata where driver = '$_COOKIE[username]' AND amount >=
$_POST[txtLowAmount] AND amount <= $_POST[txtHighAmount] AND restaurant
regexp???

I'm not even sure if that is where a regexp belongs or if that is how it
should be used.
Ultimately, I would prefer it be non case sensitive.
Here are some examples of what I want:

If the user string is "CHIL"
Chili'strue
Charlie'sfalse
CHILtrue
chfalse

Simple Code Needed
Just need a little code to transfer a user to a custom error page if connection to the database fails.
Like:
If(no connect){
header("location: error.php");
}

Just need the "no connect" part I guess.

Lemans Terms Needed
So can someone tell me in lemans terms what does LEFT JOIN do in MySQL? I see it more and more and have read the manuals but still don't understand. Maybe it's a mental block going on.

UPDATE / REPLACE - Assistance Needed
I have a table called COMPANY which holds 5,000 records
Fields: Company_ID (int:2), Name (varchar:100), State_2letter (varchar:2)
i.e. 1, ABC Company, AL
I have another table called STATE (51 records)
Fields: State_ID (int:2), State_2letter(varchar:2), State_Name (varchar:100)
i.e. 1, AL, Alabama
I want to change the structure of the COMPANY table to hold the STATE's table STATE_ID record to correspond with the State_2letter. But in the same time change the STATE_2letter to be an INT format too.
So, my COMPANY table will look like this...
i.e. 1, ABC Company, 1
I just cant find my solution on how to to an UPDATE command correctly.



Advice Needed On Database Schema
I am trying to come up with a proper database schema for this situation that's at least 3 NF. I'm just having trouble with a few of the associations.

First, here's the situation.

I want to store information about all the cards in a Tarot deck.

In the deck, there are two types of cards; namely the major and minor arcana.

Both of these have some common information I want to store, and I want to be able to choose just a random card, but they also have some data unique to each, and I also would like to choose a random card of a specific type.

For example, both types have an associated element. I will have an elements table probably with simply id and name, and perhaps an element_id in the main cards table.

Both also have an associated planet and zodiac sign. Most of the major arcana cards have either a planet or zodiac sign, but not both. Also the association is a little different. With the minor cards, the planet is a specific decanate within the sign. I guess that might not matter too much though in the storage of the data, though again it might if I wanted to retrieve the planets associated with the decanates of a sign.

Further, the major arcana have a specific Hebrew letter associated with each card, while the minor cards have no such associated letters.

Finally, each of the major arcana cards are classified as elemental, planetary, or zodiacal. The minor cards have no such classification.

So, how should I store these data? They are both cards, and have some common data, but both have very different data as well.

Complex Select (Possible Subselect Needed?)
I have a table, b5_assignment_lookup, that is used elsewhere as a lookup but I'm trying to use the data contained by itself here. The table:

CREATE TABLE b5_assignment_lookup (
as_id int(11) NOT NULL auto_increment,
as_blog int(11) NOT NULL default &#390;',
as_blogger int(11) NOT NULL default &#390;',
as_milestone enum('start','finish') NOT NULL default 'start',
as_timestamp timestamp NOT NULL default CURRENT_TIMESTAMP,
PRIMARY KEY (`as_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=222 ;
By running this query, I get the following resultset:


mysql> SELECT * FROM b5_assignment_lookup WHERE as_blog = &#3989;' AND as_timestamp <= &#55614;&#57158;-09-30'
+--------+----------+-------------+---------------+---------------------+
| as_id | as_blog | as_blogger | as_milestone | as_timestamp |
+--------+----------+-------------+---------------+---------------------+
| 87 | 89 | 41 | start | 2006-05-01 00:00:00 |
|208 | 89 | 41 | finish| 2006-09-02 11:55:27 |
|209 | 89 | 103 | start | 2006-09-02 11:55:27 |
+--------+----------+-------------+---------------+---------------------+
3 rows in set (0.00 sec)
What we have here is that Blogger 41 began writing on Blog 89 on May 1, and on Sep 2 Blogger 103 took over for Blogger 41.

What I really need to grok is all bloggers who blogged all or a part of a range of dates.

For example, I really want to find out which bloggers blogged on blog 89 for all or part of 2006-09-01 to 2006-09-02.

I use this dataset as an example, but we might have completely different circumstances such as Blogger 20 being replaced on the third day of the date range, being replaced by blogger 29 for 10 days and then quitting due to lack of time and the blog going unmanned for 5 days before Blogger 20 decides to step back in on day 25.

The flags are the start/finish, obviously.

Help Needed Merging 2 Different But Similar Tables
Can someone tell me how I can import tables from another non-Joomla mysql file into Joomla? Basically it is just from one mySQL database into another. I use phpMyAdmin to import and export the entire file but I don't know how to do queries. I tried exporting the source database and then renaming all the database names to match the ones I want to merge into but all that happened was a new table was created - no merging. I really just want to select the relevant 3 fields and match them up with the fields in the database table I want to import into. I have an old program that listed all the fields of database 1 in one column and database 2 in another and all I had to do was drag the fields across to make a match and the program did the rest. Perhaps there is a similar one out there?

What I am trying to do is import all the articles I have built up using ccTiddlyWiki into Joomla. The only table names of relevance from the source file are:

id - title- body

IN other words, just the bare essentials.

The target files has a table called jos_content with columns:
id - title - title_alias - introtext - fulltext in that order and others but are not important.

I think it is fairly simple but I am not trained enough. I have 200 items so it would save an enormous amount of time!

It seems easy but I don't know enough about queries to do it well. I'm hoping that I can import the articles and then just go through the list in Joomla adding subtitles and so on to conform to Joomla database essentials.

Help Needed For Inserting Using Variables In A Loop
im trying to dod a simple insert into my database but the thing is instead of having stable variables i need to input balues from within a loop.

heres the code but i cant figure out whats wrong with it: :mad:
<?
include "login.inc";
$i=1;
while ($i < $num):
$query="insert into A(B,C,D) values('$E$i','$F','$G$i'";
$result = MYSQL_QUERY($query);
$i++;
endwhile;
print("thank you");
?>

so wot should happen is E1, F, and G1 are entered into the database the first time round and then E2, F, G2 and so on until i=$num.

Help Needed For Query Involving JOIN
I have two tables populated during the use of an application to log
user events and application states. They are named "EventTable" and
"StateTable" and the structures follow:

Backups Of Raw Db Files - Indexes Needed?
Right now I am backing up mysql 4.0.14 on Windows2000 with
a scheduled batch file that shuts down the mysql service - copies
the entire data directory to a ackup directory, and restarts the
mysql service. this ackup directory then goes onto tape a couple
of hours later via veritas remote backup agent. I have tested a
restore of this backup method and it works fine. Now I would like
to add some more indexes to a table that has 11 million rows, however
the index files will be very large.

Is it necessary to backup index files? In case a restore was needed, I could
just recreate the indexes manually (via a batch file with the correct index
commands).

Will mysql choke if the table definition shows an index - but the index file is
missing? are there any "bad things" that will happen if index files are missing?

Libmysqlclient.so.10 Is Needed By (installed) Mod_auth_mysql-1.11-12
Redhat 9.0
Mysql 3.23.56 ==> Running

I want to upgarde to 4.0.13 but this is the error it says:

[root@localhost downloads]# rpm -Uvh MySQL-server-4.0.13-0.i386.rpm
warning: MySQL-server-4.0.13-0.i386.rpm: V3 DSA signature: NOKEY, key ID
5072e1f5

error: Failed dependencies:
libmysqlclient.so.10 is needed by (installed) mod_auth_mysql-1.11-12
libmysqlclient.so.10 is needed by (installed)
perl-DBD-MySQL-2.1021-3
libmysqlclient.so.10 is needed by (installed) php-mysql-4.2.2-17.2

If i install with -i will it install with the backward compatibility, it
should not break those dependencies.

Backups Of Raw Db Files - Indexes Needed?
Right now I am backing up mysql 4.0.14 on Windows2000 with
a scheduled batch file that shuts down the mysql service - copies
the entire data directory to a ackup directory, and restarts the
mysql service. this ackup directory then goes onto tape a couple
of hours later via veritas remote backup agent. I have tested a
restore of this backup method and it works fine. Now I would like
to add some more indexes to a table that has 11 million rows, however
the index files will be very large.

Is it necessary to backup index files? In case a restore was needed, I could
just recreate the indexes manually (via a batch file with the correct index
commands).

Will mysql choke if the table definition shows an index - but the index file is
missing?

are there any "bad things" that will happen if index files are missing?

Whats Needed On Client PC And Server?
I'm currently using MySQL 5.0.9 with Visual C++ 6.0 and Qt. My project is on the server, with all the dll's needed as well as MySQL with my database. I can only access my database on the server from a client station if this client station also has MySQL installed. It doesn't even execute the queries in my code.

Do I need to use server scripts and if so how do I do it? Is there in Windows something like a mysql-server and mysql-client package? Do we need to install MySQL on all of the client stations?

Multiple WHERE X='$x' In A Query. (Quick Answer Needed)
My query works when I only use one WHERE instance, but not with both, and i know I have data that matches both criteria. Is this the proper way to pull results that match 2 criteria?

$query = "SELECT * FROM Cartridges WHERE TYPE='$TYPE_Query' & PRINTER='$PRINTER_Query' ORDER BY ID ASC";

Help Needed With Load Data Infile Syntax
I'm relatively new to MySQL, and I've never used the Load Data Infile command. I'm having trouble getting it to work correctly. I have a comma separated file generated as output by another program that I can't seem to parse correctly. It contains data similar to the following:

VAL1, LASTNAME, FIRSTNAME, ADDRESS1, ADDRESS2, ETC1, ETC2, ETC3
VAL2, "LASTNAME, JR.", FIRSTNAME, ADDRESS1, ADDRESS2, ETC1, ETC2, ETC3

The "LASTNAME, JR." hoses up the import. It imports "LASTNAME into one field and JR." into another.

Manual Cascade Delete Implementation Needed
I am trying to manual clean up a child table when parent table records are deleted.

I tried:

DELETE FROM agencyImage WHERE imageID IN
(SELECT images.imageID FROM images LEFT OUTER JOIN agencyImage ON
(images.imageID=agencyImage.imageID) WHERE agencyImage.imageID is null)

This failed because you can't delete from a table that you are looking at. So how do I delete the record from agencyImage table if no record exist in the parent images table?

Help Needed Fetching Data From Table (string Matching)
I have a table "officers" table two with 4 fields all with variable char which will end up just being names. However, I need to create a report that counts each the occurance of each name and ouputs the name with the count next to it. The names in table "officers" are concatinated from a first name field and last name field in a separate table "persons";

I need some help figuring out how to write this using PHP.

Get Goals/assists For Each Game, And Player Name (was "Little Help Needed")
I have the following query:


$result = @mysql_query("SELECT g.date
, g.weeklabel
, g.gmtime
, g.home_score
, g.away_score
, g.inputted
, th.teamname AS hometeam
, th.id AS homeid
, ta.teamname AS awayteam
, ta.id AS awayid
FROM weekly g
JOIN teams th
ON th.id = g.home_id
JOIN teams ta
ON ta.id = g.away_id
ORDER
BY g.date ASC, g.weeklabel, g.gmtime");
This works fine. However, I have another table called stats. The fields in this table are playerid, match_id, goals, assists. I have another table called league, with fields playerid, playername.

I need to join the stats table to this query in order to get the goals/assists for each game, and I would also like to join the league table in order to get the players name instead of playerid.

I have messed around with many different combinations and cant seem to get this particular query to work.

Models Where The Years Overlap (was "Query Help Needed")
I'm trying to formulate a query for the following example:

Table: model_by_year
model start_year end_year
model_1 2001 2004
model_1 2003 2004
model_2 2000 2005
model_2 1998 1999
model_3 1998 2003
model_3 2002 2006

I want a query that will return all like models where the years overlap. In other words, I'd want to return model_1 and model_3, but not model_2.

ERROR 2002 (HY000): Can't Connect To Local MySQL Server Through Socket '/var/lib/mysql/mysql.sock' (13)
I have a problem connecting to sql and can't find anything on the net to solve the problem.

I have some sql databases running on a server. when I'm root on the server and I want to login to sql I do "mysql -ustudent -p -Dwordnet30 and it works fine. when I'm logged in with the user account on the server, i get this error message:

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)

so with the same user name in mysql, i can log on when i'm root, but not when i'm the user. the grant table for the user looks like this: Code:

Can't Connect To Local MySQL Server Through Socket '/home/data/mysql/mysql.sock' (13)
I just installed mysql on linux. If I open a terminal, su to root,
then type "mysql", I am able to connect to the server and run my
queries.

If I exit out of su so that I am my own id (baisley) and type "mysql",
I get this error: Can't connect to local MySQL server through socket
'/home/data/mysql/mysql.sock' (13)

Any idea why? mysql.sock has full permissions (read/write/execute), so
it should be accessable by user baisley. If I am baisley and I run
"mysql -u mysql" (as mysql is the user that the RPM set up), it will
connect.

What I would like to be able to do is run this without having to be
user mysql all the time. How do I go about setting that up, or is it
better to run all my queries/make tables as 1 user?

ERROR [HY000][MySQL][MyODBC 5.00.11][MySQL] 2006 MySQL Server Has Gone Away
Hosting Package Environment:
ASP.NET ver 2
MySQL 5.0
FP Extensions 2003

Progression:
Developed Website Outline
Developed Database in Access2003
Migrated AccessDB to MySQL @ Hosting Service using Migration Tool.
Can connect using MySQL Admin tools and run queries fine and all data, relations etc. are there.

PROBLEM: (The heart of the matter)
Starting simple, created GridView Control using Microsoft Visual Web Developer 2005 Express, a few glitches here and there, used the MySQL Connector/ODBC v5.00.11 followed instructions. Can see database in Database Connections Window but when I try to connect the GridView Control to it I get:

"Database schema could not be retrieved for this connection. Please make sure the connection settings are correct and that the database is online.

ERROR [HY000][MySQL][MyODBC 5.00.11][MySQL] 2006 MySQL server has gone away"

Had thought that "Microsoft Visual Web Developer 2005 Express" might be messing with the ODBC driver so thought to download the .NET Connector. That's when it all went bad. The documentation does not say how to install or use the connector or where to put the files. It seems to assume that these bits of information are common knowledge and I suppose that if I had kept up with the technology it might be. But alas I didn't and it Isn't and It Don't work.

Warning: Mysql() [function.mysql]: Access Denied For User 'apache'@'localhost' (using
my script is not connecting to my database, i get this error

Warning: mysql() [function.mysql]: Access denied for user 'apache'@'localhost' (using password: NO)

Warning: Mysql_query(): Can't Connect To Local MySQL Server Through Socket '/tmp/mysql.sock' (2)
I'm trying to connect to my MySQL database (sitehosted by GoDaddy) using PHP. I am having these errors and don't understand what they mean

Warning: mysql_query(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /home/content/n/l/a/nladmin/html/v5.0_3/c_register.php on line 6
Warning: mysql_query(): A link to the server could not be established in /home/content/n/l/a/nladmin/html/v5.0_3/c_register.php on line 6

Notice: Query: SELECT * FROM types MySQL error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /home/content/n/l/a/nladmin/html/v5.0_3/c_register.php on line 6
here4
Warning: mysql_close(): no MySQL-Link resource supplied in /home/content/n/l/a/nladmin/html/v5.0_3/c_register.php on line 13

I've checked paths and connection settings and don't see any problems. My guess is now that the problem is coming from the opening and closing of the DB. my script, c_register.php uses a require_once('../mysql_connect.php') to open the connection to the database. But I also have a function definition in c_register.php that uses require_once('../mysql_connect.php') when called because it needs a connection to the DB. Here's a visual that might help:

MySQL Error Number 2003 :: Can't Connnect To MySQL Server On 'hostname'(10065)
I was running an older version of the query browser a while back to connect to an older version of mySQL (3.0) running on a linux box. The server hasn't changed, but the query browser has been upgraded to 1.1.10. I can't go back to the older version of the query browser because the machine that ran it got re-formatted so I downloaded the new version and installed it.

So ... I get the following error when I try to connect:

MySQL Error Number 2003
Can't connnect to MySQL server on 'hostname'(10065)

Interestingly, I wrote a simple PHP script to connect to the server and pull some data off of it:

How To Configure MySQL ODBC Driver To Connect To A Mysql Server On My Own Side Of The Router?
Using MS Access, I have attached to MySQL servers in other states
and other countries on the other side of my router. But when I use the
MySQL ODBC driver 3.51 to connect to a MySQL server on my own LAN,
the driver tells me it cannot make the connection. Here are the ODBC
driver connection parms:

Data Source Name: (free field - name my "my linux box" will do nicely)
Host/Server Name (or IP) - something like MSQLUserName@ServerName.net
has worked fine for me in the past. Now I'm trying 192.168.1.106
Database Name - whatever, mysqldb works fine, any valid db

User - root
Password - myrootpass

Port - 3306 has worked fine 4 me N the past. Dunno whether 2 use now
SQL Command On Connect - haven't ever put anything here

Perhaps there is some configuration in mysql user privilege for the
mysqluser "root" that would prevent him from logging from a remote PC
to the mysql server?


Copyright © 2005-08 www.BigResource.com, All rights reserved