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




What Is The Sql Way To Restrict "superadmin" Priv To One User?


Is there some way to restrict in mysql that certan field has only ONE ROW
with CERTAIN VALUE X while other rows can have any values but not this
one(so "unique" is not the answer..)?

This can be of course done in application level, but it would just be nice
to know. I would build my application so that only one user can be
superadmin, while others are normal admins or something else.

Of course this restriction would not be enough anyway, because I still need
to figure out what happens in different cases. So actual benefit would be
close to zero, but nerd idealist inside of me requires to know - "we have a
right to know".




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Relations In "CASCADE", "SET NULL", "NO ACTION", "RESTRICT", "--" ?
what do they mean to set the relations of a Foreign KEY in "CASCADE", "SET NULL", "NO ACTION", "RESTRICT", "--" ?

Single Query For No Of Hits "Today", "This Month", "This Year"
Is it possible to construct a single query that fetches the no of pageviews "today", "this month", "this year" and "total since start"?

The table is very simple, one field for Date (YYYY-MM-DD) and one for the no of pageviews this day.

If not, would it be much slower/faster to divide the query into 4 different queries?

User Problems... Only Root User "works".
i have been trying to figure this strange problem out for a week or so. here it is.

i have a set of users with various permissions for different reasons. about 2 weeks ago, my hardware suffered a fairly nasty failure. i recovered everything. things seemed to work out. i didnt think to check my phpBB forums or my blog (or other mysql based stuff). never had any problems with the DB... so, maybe i am missing something simple here. i hope so.

what my users can do:

they can log in via command line, a gui i use on mac os x and it does not matter if it is local, or remote. they work just fine.

what all but one users cannot do:

none of my users can run phpbb or the blog stuff.. except for the root user. any other user returns the error message written in the code of which ever script i try to access telling me that "could not connect to DB" etc..

root works fine.

now, i thought maybe it was a problem with the forums and other stuff. but i cant be. same thing happens with all things... even a game server i occasionally run that keeps account info in a DB.

all these users are set up properly and have worked just fine in the past. nothing new has been installed, no conf changes..im at a loss...

Unable To Connect To Server (was "Novice User Problem")
I've been reading Kevin Yank's Build Your Own Database Driven Website and am unable to connect to the MySQL server as he describes in Chapter 4 (p. 74-75).

After modifying his code to produce a mysql_error, I get:

Unable to connect to server at this time.Client does not support authentication protocol requested by server; consider upgrading MySQL client

Even though I am using the latest MySQL server (5.0).
My
?php

$dbcnx = @mysql_connect('localhost', 'root', 'my_actual_password');
if (!$dbcnx) {
exit('<p>Unable to connect to server at this time.' . mysql_error() . '</p>');
}

if (!@mysql_select_db('ijdb')) {
exit('<p>Unable to locate the joke database at this time.</p>');
}

?>
<p>Here are all the jokes in our MySQL database:</P.
<blockquote>
<?php
$result = @mysql_query('SELECT joketext FROM joke');
if (!$result) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while ($row = mysql_fetch_array($result)) {
echo '<p>' . $row['joketext'] . '</p>'
}
?>

List All Clients Not Assigned To Current User (was "Query Help Please")
I have two tables like this:

*clients
-- client_id
-- client_name

*manage
-- user_id (multiple entries possible)
-- client_id

To assign clients to users there is a entry in the manage table of the
user_id and client id.

I want to list all the client_ids and client_names that are not assigned to the current user_id say 1.

Access Denied For User 'root'@'localhost' (was "help!!! Just A Beginner..")
Hello i recently installed WAMP5 to handle my phpmysqlapache localhost sever. but when i go to the control panel and clicked the localhost and phpmyadmin everything seems fine because i can see the phpinfo window and also the phpmyadmin.. but not when i clicked the SQLite Manager.Unable to connect to database manager.
Could not connect: Access denied for user 'root'@'localhost' (using password: YES).

ERROR 1045: Access Denied For User: '&quot;root&quot;@localhost' (Using Password: YES)
I have been working on this for three days (about 16 hours) to no avail. I have root access on a dedicated server running whm/cpanel on Redhat 9. I have followed every instruction from mysql.com as well as every suggestion I've been able to find.

These are the two errors I bounce between:

ERROR 1045: Access denied for user: '"root"@localhost' (Using password: YES)

and

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

I'm out of ideas.

How To Change &quot;#1226 - User 'root' Has Exceeded The 'max_questions' Resource&quot; Error
I seem to have set a max_questions variable on my system and my admin console and command prompt don't work with this response:

"#1226 - User 'root' has exceeded the 'max_questions' resource"

How to fix?

And how do I not make thisw mistake again?

Count User Comments In Each Category (was "help On A Query")
I would really appreciate if someone could help me out on this one. this are my tables:

comments

Comment_ID
Video_ID
Comment_Text
Comment_UserID
....
video
Video_ID
Category_ID
.....
category
Category_ID
Category_Name

I'm trying to get a user's count of comments for each category, ordered by the number of comments DESC. basically, I want to show the top categories where the user has posted the highest number of comments.

so far this query gets me the category name of where the user has posted:


PHP

$SQLTemp = "SELECT Category_Name
            FROM category
            WHERE Category_ID
            IN (
            
            SELECT DISTINCT (    Category_ID        )
            FROM video
            WHERE Video_ID
            IN (
            
            SELECT DISTINCT (    Video_ID        )
            FROM comments
            WHERE Comment_UserID = $id
            )
            )";

THANKS!!

Find All Games A User Has A Top 3 Score In (was "Need Help With A Query")
I am trying to create a query that will go through a scores table for me and find all the games that a user has a top 3 score in. Here are the table that are relevant I think...

CREATE TABLE files (
fileid int(11) NOT NULL auto_increment,
file text NOT NULL,
icon text NOT NULL,
filelocation int(1) NOT NULL default &#391;',
iconlocation int(1) NOT NULL default &#391;',
customcode text NOT NULL,
title text NOT NULL,
description text NOT NULL,
keywords text NOT NULL,
width int(11) NOT NULL default &#390;',
height int(11) NOT NULL default &#390;',
category int(11) NOT NULL default &#390;',
timesplayed int(11) NOT NULL default &#390;',
status int(1) NOT NULL default &#390;',
filetype int(2) NOT NULL default &#390;',
dateadded date NOT NULL default &#55612;&#57200;-00-00',
rating int(11) NOT NULL default &#390;',
totalvotes int(11) NOT NULL default &#390;',
totalvotepoints int(11) NOT NULL default &#390;',
scores enum(&#390;',&#391;') NOT NULL default &#390;',
PRIMARY KEY (fileid)
) TYPE=MyISAM AUTO_INCREMENT=2285 ;

CREATE TABLE scores (
scoreid int(11) NOT NULL auto_increment,
fileid int(11) NOT NULL default &#390;',
score int(11) NOT NULL default &#390;',
username text NOT NULL,
userid int(11) NOT NULL default &#390;',
usercomment text NOT NULL,
dateadded date NOT NULL default &#55612;&#57200;-00-00',
PRIMARY KEY (scoreid)
) TYPE=MyISAM AUTO_INCREMENT=16 ;

CREATE TABLE users (
userid int(11) NOT NULL auto_increment,
username text NOT NULL,
password text NOT NULL,
email text NOT NULL,
status enum(&#391;',&#390;') NOT NULL default &#390;',
usergroup int(11) NOT NULL default &#391;',
joined date NOT NULL default &#55612;&#57200;-00-00',
played int(11) NOT NULL default &#390;',
comments int(11) NOT NULL default &#390;',
avatar text NOT NULL,
avatar_uploaded enum(&#391;',&#390;') NOT NULL default &#390;',
location text NOT NULL,
website text NOT NULL,
gender int(1) NOT NULL default &#390;',
favourite int(11) NOT NULL default &#390;',
receiveemails enum(&#391;',&#390;') NOT NULL default &#391;',
newpm enum(&#391;',&#390;') NOT NULL default &#390;',
confirmation text NOT NULL,
PRIMARY KEY (userid)
) TYPE=MyISAM AUTO_INCREMENT=8 ;
(
Basically the query would need to search through the scores table to find if the specified user $userid has the top 3 (by top 3 i mean 1st, 2nd, or 3rd highest score) scores of any game in the scores table. The end resukt would be a list that contained the fileid of the game the user has a top 3 score in, the actual score, and the position (1, 2, or 3) Im not sure if I am even explaining this right cause im kind of tired. I am a novice MYSQL user but this just has me stumped

Displaying User Last Login Like "3 Days, 2 Hours Ago"
I have a table "user" with a field "lastlogin" that stores a basic datetime of the last time the user logged in
Do you know of a fast function or class that can convert that field into a more readable "User last logged in: 3 days, 2 hours ago" or something similar?
I've seen this everywhere and I don't like reinventing the wheel

What Privileges Need A User To Run &quot;SHOW SLAVE STATUS&quot; ?
i use mysql 4.1.22
i need to create an user who must have rights to run only "SHOW SLAVE STATUS" query.
from online documentation i wasn't able to find what privilege i must grant to this user to be able to do only this query.

User Names For Both Players (was "I'm In A Bit Over My Head")
I have two tables:
* users, with field user_id and user_nick
* games, with field player1_id and player2_id
games.player1_id and games.player2_id are foreign keys for users.user_id

If I only have one player in games I would do

SELECT games.player1_id, users.user_nick FROM users, games WHERE users.user_id = games.player1_id
However, now that i have two players, and i want the nicks of them both, how would I go about it? Is it possible in one query only?
Of course this the following doesn't work, but something like this?:

SELECT games.player1_id, games.player2_id, users.user_nick AS player1_nick, users.user_nick AS player2_nick FROM users, games WHERE users.user_id = games.player1_id

"Access Denied For User" Mystery
I'm having an odd problem. I have a MySQL database, and am trying to connect to it through PHP. I've done this before. However, when I try to connect a particular user, I get:

Could not select database because Access denied for user 'myuser'@'localhost' (using password: YES)

If I change my PHP script to login as root, everything works fine, so it doesn't seem to be a PHP&MySQL configuration issue. Also, I CAN login as "myuser" through the MySQL command prompt AND access the database I'm trying to use in the PHP script.

Any ideas why a user would be able to access a DB through the command line, but not through a PHP script? I granted them all privileges on the database. I've retyped the password several times.

Searching For Numbers - &quot;close To&quot; Or &quot;approximate&quot;
I would like to know how to search a table for records where a particular field is "close to" a particular number.

For instance, let's say I have a table containing students and their most recent test scores. I'd like to see students who scored 7/10. That's easy enough (select * from table where score = 7). I'd also like to run another query to identify other students whose scores are not 7 but "close to" 7. Ie students who scored 6 or 8.

As an added bonus, I'd like to be able to do a related search that shows students who scored 7, then shows the other students ordered by how "close" they are to 7. Ie students who scored 6 or 8 are "closest" matches, and students who scored 1 are "furthest". I hope this makes sense!

Is there any pre-existing MySQL command that will do this? Or will I have to run separate queries for each value?

REQ: MySQL 4.0 Equivilent Of "DateDiff("m", Date, Now())=1"
I have a query that works in the rest of the SQL world

"SELECT invoice.*, invoice.Date
FROM invoice
WHERE (DateDiff("m", Date, Now())=1);"

which will give me all of last month's invoices.

However it doesn't work with MySQL 4.0.

While

"SELECT
Invoice.*
FROM
invoice
WHERE
(Month(Invoice.Date) = ((Month(Now()))-1))"

Is a close substituent, it will blowup in January.

Anyone have an equivalent expression for MySQL 4.0?

Value &quot;000&quot; Stored As &quot;0&quot; In Text Field?
I've managed to import my data from a CSV using SQLyog Enterprise, however, I have a problem with the table storing the text value "000", MySQL truncates it to "0", unfortunately, I need the value to be stored as "000", does anyone know of any way that I can force the field to store all the characters, rather than treating it as a number? Surely a text field should treat any numbers stored within it as text?

Return A &quot;true&quot; Or &quot;false&quot;
i wanna do a "select", where if the script finds any matches, i dont wanna know about them. Instead, i just want it to return a a value: true (1) ou false (0).

ie.:

$sth = $dbh->prepare("SELECT * FROM maps WHERE name='algo' LIMIT 1");
$sth->execute();

if (match is true) {
print "True Match. A match was found";
}
else {
print "False Match. No matches were found.";
}

"Group By" Forgets "Order By"
I'm trying to build a simple RSS reader for a client and am running into some serious problems with the GROUP BY in MySQL. Basically I have two tables: one that holds all the entries and one that holds all the feeds. Then what I can do is say:
[MYSQL]SELECT * FROM entries WHERE feed_id='13' ORDER BY date DESC[/MYSQL]
That will select all the entries that belong to feed #13. This is fine, but what I'm doing now is building a library that will display the feed_id with the latest entry with that id. So I would think it would be something like the following:
[MYSQL]SELECT * FROM entries GROUP BY feed_id ORDER BY date DESC[/MYSQL]
That should get me the single latest entry from each feed_id. However it's forgetting the ORDER BY clause all together and seemingly ordering it by the auto-incrememnt value in the entries field.

REGEXP To Find "foo-bar" And "foo Bar"
Does somebody know how to solve this:

select * form geo,places where  geo.name = places.name

Where geo.name could be New York
and geo.places could be New-York

"Select * FROM" Vs "Select Field1,field2 FROM"
No matter how many fields I want to retrieve from the table I always use "Select * FROM Table" instead of "Select field1,field2 FROM Table".

Are there any disadvantages of always using "Select * FROM Table"?

Select &quot;german, French&quot; Only With &quot;german&quot;
in a table I have this entry in the column "language":

"GERMAN, FRENCH"

how do i have to make/modify my mysql-syntax so that i can select the entry abowe only with the word: "GERMAN"? Is this possible or do i have to make a data manipulation first?

&quot;Calculated Fields&quot; In &quot;
o I want to create a table "totals" with three following fields:
Field 1 => quantity
Field 2 => unit_price
Field 3 => quantity*unit_price

o I thought I could do something like:

=CODE=============================
CREATE TABLE totals
(
quantity INT,
unit_price DOUBLE,
total DOUBLE AS quantity*unit_price
);
==================================

o It fails with the following error:

=REPORT===========================
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 'AS quantity*unit_price)'
==================================

Question1: Is it possible to declare "calculated fields" at "table creation" ?
Question2: If yes, how to do so?

WHERE `user` = " . $user . "
Is there a way to check that in a column there is an entry with the same string indepentant of capitalization??

Maximum Execution Time Of 300 Seconds Exceeded (was "MYSQL Error")
I have a huge database 400mb+ in size which i have exported into a .sql file. I tried to run this export script into a new database and it runs fine until three quarters into the scripts execution and the following error appears:

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 '<br / >
<b>Fatal error</b>: Maximum execution time of 300 seconds exceeded in <b' at li ne 1
I believe this error may relate to "delayed_insert_timeout = 300". How do I increase this limit in mysql - maybe it may solve the problem but then again it may not .

Any advice is most gratefully appreciated - As you can imagine if the script runs fine for 3/4 of it and then an error appears, stating the error is on line 1, it will take me days to go through the whole script (hundreds of thousands of rows) to find the error as I assume the error does not reside on line 1 as this line would have been executed.

I am running the script on mysql 5, and via source /path/****.sql on linux.

Error "Can't Find FULLTEXT Index Matching The Column List"
I'm trying to use fulltext search with mysql match() against() but i keep getting this error
Can't find FULLTEXT index matching the column list

even though i already altered the table to make the column im searching FULLTEXT

any ideas?

Design For Stock Items And Checkin/checkout Process (was "Query Help")
I'm currently in the process of trying to bodge together a simple(ish) stock system to be used on a company intranet but I've ground to a halt with a particular problem.

Using a MySQL database I've got tables with 11 fields, including 'Quantity' (self explanatory) and BookOut. Now this BookOut field contains information on the user who has booked out an item including the users name, the date/time etc

The problem I have is this. If an item has a quantity of 7 and a user books out 1, then his/her info is stored in BookOut but when another user books out another 1 of said item at a later stage then the previous BookOut info is overwritten.

Is there a way in that everytime another item is booked out that a new line is created within a specific field?

}

if(!sizeof($error)){

$update_SQL = "Update joystick Set BookOut = '" . mysql_real_escape_string($BookOut) . "', PCserial = '" . mysql_real_escape_string($PCserial) . "', Quantity = Quantity - " . $Quantity . ", MachineNo = '" . mysql_real_escape_string($MachineNo) . "', Date = now() WHERE ID = " . $ID;
if(! @mysql_query($update_SQL)){

$error[] = "Update SQL failed";

}
The above is the query I am currently using. I'm not totally proficient with .php and have already had a lot of help getting this far.

Query To Populate A Calendar (was "Wanted The Experts Opinions (that Means YOU!)")
I am building my first calendar for a client to list All their events on a month to month basis.

There are several tables of data that I need to query to populat the calendar from: Events, Committee Meetings, Lectures, and Group Actions.

I was wondering:

#1) Is it more effecient to query all the tables once and to store the results into an array that I can check as I loop through and output the days for the calendar?

#2) OR, is it better to query all the tables for each day as I loop through and construct the calendar ouput?

After formulating my question it seems like a no-brainer: That option #1 would be the most effecient, but I still would like to know your opinions. Especially if you have made a calendar before.

Searching A Comma Separated List Of Numbers (was "Brain Toot")
I'm at burnout point and simply cannot remember how to do this in a MySQL query.

I have as an input from a form:

&#391;,4,6,8,55,74,11123'

Basically a comma separated list of numbers

The table I'm accessing has multiple records with a column called 'areas' this column for each may contain some of multiple of these input form numbers. e.g.

row 1 &#393;,1,76,77,89,400'
row 2 &#391;,2,7,8,55'
row 3 &#391;,4,6,8,55,74,11123'

I need to return any row that has at least 1 matching value from the form input list.

I literally staring at the screen after a marathon coding stretch and cannot get the mind in gear.

Store Web Site Club Registration Data (was "MySQL Question")
I am working on a website for a club. One thing that they want included in the site is a way for people to register online for the club and their services and for this information to be put into a database for the owners to view. Is this something that I can do with MySQL?

Batch Mode Feedback Of &quot;mysql&quot; Command Line Tool
while writing a bash shell script to backup some databases and I am having slight problems with the mysql command line tool's feedback.

Here goes command line:

#!/usr/bin/env bash
mysql -ubackup -e "UPDATE `mydb`.`sysvar` SET `val`='backup' WHERE `var`='updateState' AND `val`='0';"

The backspaces are nescessary for the shell, otherwise it'd interpret whatever is inclosed in --> ` <--- as command.

The problem is, I need to know wether a line has changed or not. The command always returns 0 (that is a success in Unix/Linux) if it was successfully executed, no matter wether or not a line had been changed, and produces no output at all.

Could anyone tell me how I get that info?

Full Text Search - Un-stopping Default Stop Word &quot;first&quot;
using a full text query with the word "first" does not return any rows. I would like to remove the word "first" from the default stop word list ?

Encountering 2013 Error ("Lost Connection To MySQL Server...")
I have a nightly job that performs backups on my MySQL servers. There are three production MySQL instances on different machines. My backups have been running successfully for months (until now).

However, on last night's backups for one instance, a couple of database/schemas (appear to have) backed up successfully, but the larger schemas failed, as follows:

=======================================
Backup of schema dhunt was successful in 0 seconds
Backup of schema mysql was successful in 0 seconds
Backup of schema support_appl was successful in 0 seconds
Error: Backup of schema support_dict was not successful (1115 seconds):
mysqldump: Got error: 2013: Lost connection to MySQL server during query when retrieving data from server
Error: Backup of schema test was not successful (0 seconds):
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) when trying to connect
=======================================

I re-ran the backup cron job with the same results. Does anyone have any troubleshooting suggestions?

Generating DAILY Min&amp;Max Over A Period Of Time, Based On A &quot;DateTime&quot; Field
how to print the minimum and maximum of a specific field, between two datetimes (both having the time 02:00:00) - so I did this:

WHERE ((tblvalues.dtLPDateTime)>="2006-01-01 02:00:00" And (tblvalues.dtLPDateTime)<"2006-01-03 02:00:00"))

Now I want to print those min and max values but for each day in this cycle, i mean, for this example, there would be two records like:
Day Min Max
2006-01-01 02:00:00 -> 2006-01-02 02:00:00 | 40 | 59
2006-01-02 02:00:00 -> 2006-01-03 02:00:00 | 49 | 68
where at this point i`m getting min=40 and max=68

"supplied Argument Is Not A Valid MySQL Result Resource" Error
i am getting this error with the following code:

$query = "SELECT title, firstname, surname, address1, address2, address3, postcode,"
."tel, mobile, email"
."FROM user"
."WHERE username='$valid_user'";

us.skill_id=s.skill_id"

$result=mysql_query($query);
$num_rows=mysql_num_rows($result);
$row=mysql_fetch_array($result);

The error is referring ot the last 2 lines of this script.

Linking Stores With Products (was "MySQL Dificult Code")
I have a MySQL database dificult (for me anyway..).
I have a ecommerce site with a table of products.
Now I want to create a new table with a list of stores where clients can find near home those products. In a limit situation I can have a list of all products indexed in one store (and the products list is increasing everyday, the same with the list of store...). I want this feature to be capable of introdution of new products in a store that already as several products.
My idea is to develop 3 tables:

Products
+----+-----------+--------------+
| id | name | description |
+----+-----------+--------------+
| 1 | xxxxx | aasa... |
| 2 | vvvvvv | asasasasas... |
+----+-----------+--------------+


Stores
+----+-------------------+-----------+
| id | store | address |
+----+-------------------+----------+
| 1 | aaaaa | street1... |
| 2 | bbbbbb | street2... |
+----+-------------------+-----------+



Linking stores with products
+----+-------------------+-------------+
| id | store id | products id |
+----+-------------------+-------------+
| 1 | 1 | 1;2 |
| 2 | 2 | 2 |
+----+-------------------+-------------+

Can I implement this in MySQL? I mean how can (if I can) place several ids in a field? and how can I do the query in order to list the products inside a store?
Hope that I made my self clear. If not please do not hesitate to request further information.




What Is Execution Time Of A Query Based On? (was "a Mysql Question")
when selecting data from the database, does the time taken to retrieve it vary from 56k connections to T3 connections? or does it all depends ont he general server speed/amount of connections on the db?

im not sure if ive explained that in the best way for people to understand
but im sure someone will get what i mean

Unique Combinations Of Model And Make (was "Query Question")
I'm trying to write a query and was wondering if someone could help me formulate it. Here is an example table I'm working with:

Table: vehicles
Model Make
Ford Taurus
Ford Taurus
Ford F150
Chevy Tahoe
Chevy Blazer
Chevy Tahoe

I want a query that returns all unique combinations of model and make. So the result set should be:
Model Make
Ford Taurus
Ford F150
Chevy Blazer
Chevy Tahoe

I know how to return distinct values for one variable, but not for two like that. Any help is greatly appreciated.

Return 1 Row With Concatenated String (was "Really Easy But My Minds Gone Blank")
I'm creating a website for my local American Football team and the database structure is as follows:

CREATE TABLE players
(
`PlayerId` tinyint unsigned NOT NULL,
`Jersey` tinyint unsigned,
`FirstName` varchar(12),
`LastName` varchar(20),
`ContactNumber` varchar(12),
`Email` varchar(40),
PRIMARY KEY(`PlayerId`)
);

CREATE TABLE playerposition
(
`PlayerId` tinyint unsigned NOT NULL,
`PositionId` tinyint unsigned NOT NULL,
PRIMARY KEY (`PlayerId`, `PositionId`)
);

CREATE TABLE positions
(
`PositionId` tinyint unsigned NOT NULL,
`PosAbbr` varchar(3) NOT NULL,
`PosLong` varchar(30) NOT NULL,
PRIMARY KEY (`PositionId`)
);
Now each player can play a multitude of positions say PlayerA can play QB, RB and TE. My query is as follows:

SELECT pl.PlayerId, Jersey, FirstName, LastName, PosAbbr
FROM players pl, playerposition pp, positions po
WHERE pl.PlayerId = pp.PlayerId
AND pp.PositionId = po.PositionId
Now it will return 3 rows for PlayerA, 1 row for each position they play. What I want it to return is 1 row with a concatenated string of their positions something like QB/RB/TE. My mind has just gone blank. Can anybody enlighten me on this.

P.S. I'm running 4.1 on the server.

Adjacent Theater Seats (was "mySQL Query Issue")
Having not been working with more than a simple SELECT * from table query, I am having a few issues when it comes to using more complex queries.

I am currently using a query to select seats from a database using the following query:

$query1 = mysql_query("SELECT struct.seatid, struct.row, struct.seatnum FROM seats as seat LEFT JOIN structure as struct USING (seatid) WHERE seat.showtimeid=".(int) $_GET['id']." && seat.available = &#391;' && seat.timelimit < $minutes2 ORDER BY seat.seatid ASC");
For each record that is selected I want to check if either of the seats either side of it are also selected, if not then it is not to be shown.

I have added a while loop below the above query and run another query following it (not sure if that makes sense, so I will paste it below!)

while($rows = mysql_fetch_assoc($query1)){

$minusseat = $rows[seatid] - 1;
$plusseat = $rows[seatid] + 1;

$queryminusseat = mysql_query("SELECT * from seats LEFT JOIN structure WHERE seat.showtimeid=".(int) $_GET['id']." && seat.available = &#391;' && seat.seatid == $minusseat && seat.timelimit < $minutes2");

$num_rows = mysql_num_rows($queryminusseat)or die(mysql_error());

echo "$num_rows";

//if($minusnum > 0){
//echo "$minusseat <b>" . $rows[seatid] ."</b> $plusseat <br/>";
//} else {
//echo "<font color=red>$minusseat <b>" . $rows[seatid] ."</b> $plusseat <br/></font>";
//}

}
The code above is used below the initial query and the following error is being displayed:

Quote:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:Program Filesxampphtdocsprojectprototype1 ickets.php on line 154
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 'WHERE seat.showtimeid=1 && seat.available = &#391;' && seat.seatid == 1 && seat.time' at line 1

Count Query Causing &quot;excessive Processor Usage&quot;
For the second time in the past 6 months my hosts have shut down my site because it was apparently causing a shared mySQL 5 server to max out at 100% usage. I'm not much a programmer, know even less about mySQL and obviously don't have access to the server from the back end but I'd appreciate any advice as to whether it is my query that is causing the problem:

Set rsMail = objConnC.Execute("SELECT * ,(SELECT COUNT(*) FROM comments WHERE comments.submissionID = submissions.submissionID AND comments.commentInclude = 1) as CommentCount FROM submissions WHERE PigeonHole = 'mailbag' AND Status <> 'hold' ORDER BY submissionID DESC LIMIT 20")

Apart from two instances, this query has been working fine on a page that receives between 10,000 and 30,000 visits a day.

The site is running on Windows and coded in ASP but is calling a separate mySQL server.

How Can I "see" A Table In A Database On A Remote MySQL Server After Creating It
I used the following SQL to create a new table in a database on
a remote MySQL server by copying one already there. I know the
table exists SOMEWHERE in cyberspace. I can read its data, write
to it, delete from it. But I cannot see it. The only way I know it
exists is by running this SQL from Access 97 pass through query:

SELECT ALL new_tbl.name FROM new_tbl

The database resides on a MySQL server that was created with
a single table (named test) in it for testing purposes. I ran the
following SQL to create another copy of the table in the same
database named: new_tbl

CREATE TABLE new_tbl SELECT * FROM test;

I cannot see the new table in the Access 97 database window
under the Tables Tab. Anybody know how to overcome this?

Its a severe drawback to programming efforts not to KNOW what
tables are in your database.

How To Modify The &quot;select&quot; Function In The Source-code-version?
I have a source-code-version of MySQL at hand,and I want to modify the "select" function to optimize it.

The question is:how can I start? I wonder whether "select.cc" is the right file I can edit.

Beta Testers Wanted For New "blueshell Data Guy Professional"
We are seeking beta testers for our upcoming "blueshell Data Guy
Professional". This new application is an extension to our
award-winning universal database editor "blueshell Data Guy" (bDg)
valuable for database professionals like DBA's, developers etc.

Although bDg serves almost all databases, we're planning to focus the
beta on MS SQL Server, Oracle, MySQL, Sybase Anywhere, Advantage DB
Server, DB2 and Jet. Nevertheless, if you want to test it against any
other DBMS, please let us know.

These are the main features of bDg Professional:

- All features of bDg Standard like schema browsing using a tree view,
table view and edit, table design, import, export, desktop
connectivity etc. (See http://www.blueshell.com/Product.asp?Prod=bDg
for product details)

- "SQL Cook" to assist you in entering valid SQL statements (something
between Intellisense and a wizard)

- Design (edit) objects like stored procedures, functions, packages,
triggers and sequences

- Easy design of table relationship (foreign keys).

Multi-table UPDATE Problem (was "mysql Question")
$sql = "UPDATE char_lair , char_main m SET l.zip_id='$zip',
l.lair_addr='$address', m.alias='$alias', m.real_name='$name',
m.align='$align' WHERE m.id = $cid AND m.lair_id = l.id";

I am using mysql v.3.23, I got error in this code but can't find the solution.
The message displayed in browser is:
---------------------------------------------------
UPDATE char_lair , char_main USING char_lair l, char_main m SET l.zip_id='z3', l.lair_addr='a3', m.alias='ch3', m.real_name='rn3', m.align='good' WHERE m.id = 2 AND m.lair_id = l.idYou have an error in your SQL syntax near ' char_main USING char_lair l, char_main m SET l.zip_id='z3', l.lair_addr='a3'' at line 1
=========================================
Is there any syntax error?

Invalid Use Of Group Function (was "Baffled By Query Error")
trying to figure out why I keep getting this error with the following query:

SELECT c.account_id,a.name,a.company,SUM(c.agent_product_time) AS mins
FROM account a LEFT JOIN calls c ON c.account_id = a.id
WHERE c.calldate >= DATE_SUB(NOW(),INTERVAL 14 DAY) AND c.agent_id = 2
AND SUM(c.agent_product_time) >= '500' GROUP BY c.account_id ORDER BY mins

ERROR: #1111 - Invalid use of group function

Compare 2 Tables And Find Rows Which Don't Match (was "Mysql Noob Question")
I have a products table and a products_description table. They both have products_id as primary key. However, products_description table has more products_id keys then the products table. How do i compare the 2 tables and show just the products_id that dont match from products_descripition table?

SELECT products.products_id, products_description.products_id FROM products, products_description WHERE products.products_id != products_description.products_id;

I tried that query but got some wierd results and also the results gave me 2 columns when I just want one.

Save A File So &quot;load Data Infile&quot; Can Use --binary Column, 0-255 Encoding
I want to backup database to a text file. There are binary columns.

I read byte[] from the column and use ASCII encoding convert it to string
and write to a text file.

But there are bytes large than 7F, and I lost 80Hex, e.g. 91Hex will be
11Hex.

Which sigle byte encoding that covers from 0-255 ?


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