Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

OT: 1 field SQL tables?

LEGEND ,
Sep 27, 2006 Sep 27, 2006
Can I have a SQL table with a single field? Do I just make it the index
field for the table? Even if it's a text field?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



TOPICS
Server side applications
8.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
replies 139 Replies 139
LEGEND ,
Sep 27, 2006 Sep 27, 2006
Murray *ACE* wrote:
> Can I have a SQL table with a single field? Do I just make it the index
> field for the table? Even if it's a text field?

Are you talking about MS SQL Server? If so, I don't know, but the answer
is probably yes.

If you're talking about MySQL, you can definitely have a single field
(column) table. There is no need to have an index. For example, a word
list can consist of a single column with no index. Normally you need an
index only if there are several fields in each record.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Same as David said for SQL Server too.

Cheers,
Rob
http://robgt.com/ [Tutorials and Extensions]
Firebox stuff: http://robgt.com/firebox
Skype stuff: http://robgt.com/skype
SatNav stuff: http://robgt.com/satnav



Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Thanks.

Yes - it's MySQL.

I'm trying to add a textarea containing a list of zip codes to a table in
MySQL. My questions are -

1. Do I need to create the table first? Seems like I do.
2. When I try to create it with a single field, MySQL is unhappy -

$mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL, INDEX(tempZip))";

or

$mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL)";

What am I missing?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efeuid$ac5$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Can I have a SQL table with a single field? Do I just make it the index
>> field for the table? Even if it's a text field?
>
> Are you talking about MS SQL Server? If so, I don't know, but the answer
> is probably yes.
>
> If you're talking about MySQL, you can definitely have a single field
> (column) table. There is no need to have an index. For example, a word
> list can consist of a single column with no index. Normally you need an
> index only if there are several fields in each record.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
On 28 Sep 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> I'm trying to add a textarea containing a list of zip codes to a
> table in MySQL. My questions are -
>
> 1. Do I need to create the table first? Seems like I do.
> 2. When I try to create it with a single field, MySQL is unhappy -
>
> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL,
> INDEX(tempZip))";
>
> or
>
> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL)";
>
> What am I missing?

You know you can sort the zipcode array you created in PHP?

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Murray *ACE* wrote:
> 1. Do I need to create the table first? Seems like I do.
> 2. When I try to create it with a single field, MySQL is unhappy -
>
> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL, INDEX(tempZip))";
>
> or
>
> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL)";

Does the user account have CREATE privileges? If not, you need to create
the table first.

Why are you using a TEXT data type for zip codes? A TEXT field holds up
to 65,535 characters. If you're storing 5-digit zip codes, use CHAR(5).
A single column table is no problem:

CREATE TABLE tblTemp (tempZip CHAR(5) NOT NULL)

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2006 Sep 29, 2006
On Fri, 29 Sep 2006 10:51:24 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>So many functions for handling strings, arrays, etc.

Aha. yes.
--
Steve
steve at flyingtigerwebdesign dot com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Yes. I don't really care about sorting it, though.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns984C488D597CFmakowiecatnycapdotrE@216.104.212.96...
> On 28 Sep 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> I'm trying to add a textarea containing a list of zip codes to a
>> table in MySQL. My questions are -
>>
>> 1. Do I need to create the table first? Seems like I do.
>> 2. When I try to create it with a single field, MySQL is unhappy -
>>
>> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL,
>> INDEX(tempZip))";
>>
>> or
>>
>> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL)";
>>
>> What am I missing?
>
> You know you can sort the zipcode array you created in PHP?
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
> Why are you using a TEXT data type for zip codes? A TEXT field holds up to
> 65,535 characters. If you're storing 5-digit zip codes, use CHAR(5).

Dunno. Will do.

Thanks!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efgbil$2d9$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> 1. Do I need to create the table first? Seems like I do.
>> 2. When I try to create it with a single field, MySQL is unhappy -
>>
>> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL, INDEX(tempZip))";
>>
>> or
>>
>> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL)";
>
> Does the user account have CREATE privileges? If not, you need to create
> the table first.
>
> Why are you using a TEXT data type for zip codes? A TEXT field holds up to
> 65,535 characters. If you're storing 5-digit zip codes, use CHAR(5). A
> single column table is no problem:
>
> CREATE TABLE tblTemp (tempZip CHAR(5) NOT NULL)
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
David:

In an earlier post, Tom Muck suggested that I use a temporary table to hold
this data while I de-duped it -

select distinct myfield into #holding from mytable

What does that "#holding" do? Does that create a holding area on the fly,
or must I prepare that area in advance somehow?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efgbil$2d9$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> 1. Do I need to create the table first? Seems like I do.
>> 2. When I try to create it with a single field, MySQL is unhappy -
>>
>> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL, INDEX(tempZip))";
>>
>> or
>>
>> $mysql="CREATE TABLE tblTemp (tempZip TEXT NOT NULL)";
>
> Does the user account have CREATE privileges? If not, you need to create
> the table first.
>
> Why are you using a TEXT data type for zip codes? A TEXT field holds up to
> 65,535 characters. If you're storing 5-digit zip codes, use CHAR(5). A
> single column table is no problem:
>
> CREATE TABLE tblTemp (tempZip CHAR(5) NOT NULL)
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Murray *ACE* wrote:
> select distinct myfield into #holding from mytable
>
> What does that "#holding" do? Does that create a holding area on the fly,
> or must I prepare that area in advance somehow?

AFAIK, you can't use a name like #holding in MySQL. The correct syntax
would be this:

CREATE TEMPORARY TABLE holding SELECT DISTINCT myfield FROM mytable

Again, the user account needs the correct privileges to be able to
create a temporary table. It's also a good idea to drop the temporary
table when you have finished with it:

DROP TABLE holding

It goes without saying that the user account needs DROP privileges to do
this, too.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Thanks, much, David!

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efgfs2$7v1$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> select distinct myfield into #holding from mytable
>>
>> What does that "#holding" do? Does that create a holding area on the
>> fly, or must I prepare that area in advance somehow?
>
> AFAIK, you can't use a name like #holding in MySQL. The correct syntax
> would be this:
>
> CREATE TEMPORARY TABLE holding SELECT DISTINCT myfield FROM mytable
>
> Again, the user account needs the correct privileges to be able to create
> a temporary table. It's also a good idea to drop the temporary table when
> you have finished with it:
>
> DROP TABLE holding
>
> It goes without saying that the user account needs DROP privileges to do
> this, too.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
David:

I now have this -

$mysql="CREATE TABLE tblTemp (tempZip CHAR(5) NOT NULL)";
mysql_query($mysql, $selectData) or die(mysql_error());
....
$mysql_insert="INSERT INTO tblTemp (tempZip) VALUES ('".$zipArray[$i].")";

I'm not getting any values inserted into tblTemp, although the table is
being created.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efgfs2$7v1$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> select distinct myfield into #holding from mytable
>>
>> What does that "#holding" do? Does that create a holding area on the
>> fly, or must I prepare that area in advance somehow?
>
> AFAIK, you can't use a name like #holding in MySQL. The correct syntax
> would be this:
>
> CREATE TEMPORARY TABLE holding SELECT DISTINCT myfield FROM mytable
>
> Again, the user account needs the correct privileges to be able to create
> a temporary table. It's also a good idea to drop the temporary table when
> you have finished with it:
>
> DROP TABLE holding
>
> It goes without saying that the user account needs DROP privileges to do
> this, too.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Murray *ACE* wrote:
> $mysql_insert="INSERT INTO tblTemp (tempZip) VALUES ('".$zipArray[$i].")";
>
> I'm not getting any values inserted into tblTemp, although the table is
> being created.

Theres's a single quote missing from your code:

$mysql_insert="INSERT INTO tblTemp (tempZip) VALUES ('".$zipArray[$i]."')";

Actually, you should be able to do this:

$mysql_insert="INSERT INTO tblTemp (tempZip) VALUES ('$zipArray[$i]')";

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Murray *ACE* wrote:
> $mysql="CREATE TABLE tblTemp (tempZip CHAR(5) NOT NULL)";
> mysql_query($mysql, $selectData) or die(mysql_error());

This is creating a new table, so it will be able to run only once.

I've no idea what you're trying to do, but it seems as though you're
tying yourself in great knots.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
LOL. It's a learning crucible.

Here's what I'm doing.

My client wants to upload a list of zip codes, match them against a master
list, and calculate % coverage (i.e., overlap) between the two.

I'm uploading the list by having them paste the zipcode list copied from an
excel file into a textarea field. This works great.

Then I'm doing the following -

1. Writing that list into a newly created table.
2. Selecting distinct from that table into a temporary holding table.
3. Truncating the newly created table
4. Selecting from the temporary table into the truncated table (now
de-duped)
5. Dropping the temporary table
6. Then I will SELECT myfield FROM mytable WHERE myfield NOT IN (SELECT
myfield FROM mastertable)

This will tell me how many of the uploaded zips were not present in the
master table, and from that information I can calculate the % overlap.

Make sense? Or do you see an even better way?


--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efglmo$fla$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> $mysql="CREATE TABLE tblTemp (tempZip CHAR(5) NOT NULL)";
>> mysql_query($mysql, $selectData) or die(mysql_error());
>
> This is creating a new table, so it will be able to run only once.
>
> I've no idea what you're trying to do, but it seems as though you're tying
> yourself in great knots.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Murray *ACE* wrote:
> Make sense? Or do you see an even better way?

Creating temporary tables and dropping them sounds like too much hard
work. You have already got the client's zips into an array, so I'll call
that $clientUpload. Create a recordset that uses SELECT DISTINCT to get
the zips from the master list. Then create a loop to get your master
list into an array:

// create master list
$masterList = array();
do {
$masterList[] = $row_recordsetName['zip'];
} while ($row_recordsetName = mysql_fetch_assoc($recordsetName));

// create array of unique zips from $clientUpload
$clientUnique = array_unique($clientUpload);

// create array of overlaps between master list and uploaded list
$overlaps = array_intersect($masterList, $clientUnique);

// calculate percentage
$percentageOverlap = count($overlaps)/count($masterList)*100;

// round percentage to 1 decimal place and add percent sign
$percentageOverlap = number_format($percentageOverlap, 1).'%';

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006

"David Powers" <david@example.com> wrote in message
news:efgol8$ji0$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Make sense? Or do you see an even better way?
>
> Creating temporary tables and dropping them sounds like too much hard
> work. You have already got the client's zips into an array, so I'll call
> that $clientUpload. Create a recordset that uses SELECT DISTINCT to get
> the zips from the master list. Then create a loop to get your master list
> into an array:

Yes, things like this are much easier in SQL Server, where you can put all
the code in a stored proc and just call it from a DTS package. I posted the
code originally before knowing the database in question.

Tom


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Although I have gotten to the stage of counting the de-duped and
non-overlapping records, and it seems to work just fine for me, Tom!

But, I will try David's recommendation, too.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
news:efgqst$mlo$1@forums.macromedia.com...
>
> "David Powers" <david@example.com> wrote in message
> news:efgol8$ji0$1@forums.macromedia.com...
>> Murray *ACE* wrote:
>>> Make sense? Or do you see an even better way?
>>
>> Creating temporary tables and dropping them sounds like too much hard
>> work. You have already got the client's zips into an array, so I'll call
>> that $clientUpload. Create a recordset that uses SELECT DISTINCT to get
>> the zips from the master list. Then create a loop to get your master list
>> into an array:
>
> Yes, things like this are much easier in SQL Server, where you can put all
> the code in a stored proc and just call it from a DTS package. I posted
> the code originally before knowing the database in question.
>
> Tom
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
Tom Muck wrote:
> Yes, things like this are much easier in SQL Server, where you can put all
> the code in a stored proc and just call it from a DTS package. I posted the
> code originally before knowing the database in question.

MySQL 5 now supports stored procedures. Unfortunately, few hosts offer
MySQL 5 at the moment. Still, I think it's a lot easier to do what
Murray wants in PHP - at least in a PHP/MySQL environment.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
I'll give it a try, David. You and Tom have been an invaluable resource to
me in this....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efgraq$n55$1@forums.macromedia.com...
> Tom Muck wrote:
>> Yes, things like this are much easier in SQL Server, where you can put
>> all the code in a stored proc and just call it from a DTS package. I
>> posted the code originally before knowing the database in question.
>
> MySQL 5 now supports stored procedures. Unfortunately, few hosts offer
> MySQL 5 at the moment. Still, I think it's a lot easier to do what Murray
> wants in PHP - at least in a PHP/MySQL environment.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2006 Sep 28, 2006
> MySQL 5 now supports stored procedures. Unfortunately, few hosts offer
> MySQL 5 at the moment. Still, I think it's a lot easier to do what Murray
> wants in PHP - at least in a PHP/MySQL environment.

Probably true. Some tasks like this I like to process offline using a custom
desktop app or a scheduled task using a DTS package calling a stored
procedure so there is no browser or application server involved.

Tom


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2006 Sep 29, 2006
David:

MUCH faster. I like it. And, it works beautifully - first time.

You are a prince. And so is Tom, but don't tell him I said this, please.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efgol8$ji0$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Make sense? Or do you see an even better way?
>
> Creating temporary tables and dropping them sounds like too much hard
> work. You have already got the client's zips into an array, so I'll call
> that $clientUpload. Create a recordset that uses SELECT DISTINCT to get
> the zips from the master list. Then create a loop to get your master list
> into an array:
>
> // create master list
> $masterList = array();
> do {
> $masterList[] = $row_recordsetName['zip'];
> } while ($row_recordsetName = mysql_fetch_assoc($recordsetName));
>
> // create array of unique zips from $clientUpload
> $clientUnique = array_unique($clientUpload);
>
> // create array of overlaps between master list and uploaded list
> $overlaps = array_intersect($masterList, $clientUnique);
>
> // calculate percentage
> $percentageOverlap = count($overlaps)/count($masterList)*100;
>
> // round percentage to 1 decimal place and add percent sign
> $percentageOverlap = number_format($percentageOverlap, 1).'%';
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2006 Sep 29, 2006
Murray *ACE* wrote:
> David:
>
> MUCH faster. I like it. And, it works beautifully - first time.

I thought you might like it. PHP is pretty nifty when it comes to
handling arrays.

> You are a prince. And so is Tom, but don't tell him I said this, please.

Your secret is safe with me. ;)

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2006 Sep 29, 2006
> I thought you might like it. PHP is pretty nifty when it comes to handling
> arrays.

It's pretty nifty in doing just about anything, really. It's SO robust....

By the way, in this routine -

// create master list
$masterList = array();
do {
$masterList[] = $row_recordsetName['zip'];
} while ($row_recordsetName = mysql_fetch_assoc($recordsetName));

the $recordsetName variable is just a dummy variable to keep the do loop
running, right?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:efj3o4$io1$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> David:
>>
>> MUCH faster. I like it. And, it works beautifully - first time.
>
> I thought you might like it. PHP is pretty nifty when it comes to handling
> arrays.
>
>> You are a prince. And so is Tom, but don't tell him I said this, please.
>
> Your secret is safe with me. ;)
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines