[PHP-DB] check two tables at same time?

2002-06-24 Thread Noah Spitzer-Williams

hey guys,

im trying to figure out a query that i can return rows from more than
one table at a time. for example, i have two identical tables in structure
and i want to return rows from both using one query. maybe this will help:

select * from table1 and table2 where condition='value'

is there any way to do this?

thanks!

- Noah

--
TradeMyTraffic! Web Services
http://www.trademytraffic.com




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] check two tables at same time?

2002-06-24 Thread Noah Spitzer-Williams

Mike,

I know quite a bit about joins and I'm not sure if they are the answer.
Basically I want to save myself two SQL statements.

I'd like to combine:
select * from table1 where cond=val
select * from table2 where cond=sameval

into one sql statement. the two tables are identical in structure thats
why i think there should be some way to do this.

Thanks!

 - Noah

--
TradeMyTraffic! Web Services
http://www.trademytraffic.com


[EMAIL PROTECTED] wrote in message
006601c21bd8$4b1fdb20$[EMAIL PROTECTED]">news:006601c21bd8$4b1fdb20$[EMAIL PROTECTED]...
 SQL JOINs...

 http://www.mysql.com/doc/J/O/JOIN.html

 -Mike

 - Original Message -
 From: Noah Spitzer-Williams [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Monday, June 24, 2002 4:21 PM
 Subject: [PHP-DB] check two tables at same time?


  hey guys,
 
  im trying to figure out a query that i can return rows from more
than
  one table at a time. for example, i have two identical tables in
structure
  and i want to return rows from both using one query. maybe this will
help:
 
  select * from table1 and table2 where condition='value'
 
  is there any way to do this?
 
  thanks!
 
  - Noah
 
  --
  TradeMyTraffic! Web Services
  http://www.trademytraffic.com
 
 
 
 
  --
  PHP Database Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] query to check valid emails

2001-11-27 Thread Noah Spitzer-Williams

what's the LIKE query to see if an email address is valid?

For example, in PHP it's something like
if
(eregi(^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$,$
email,$check)) {
echo valid;
}


i want to sort through rows in a db and look for invalid email addresses

so like, select * from tbl where email like ???

Thanks!

- Noah


--
TradeMyTraffic! Banner Exchange
http://www.trademytraffic.com





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] order by a count of another table

2001-10-05 Thread Noah Spitzer-Williams

hey guys,

i want to show a list of rows from a table sorted by the count of
another table. the first table has a username field and so does the other
table. so i want to sort the first table by how many rows that has the
username from the other table.

so something like this although i know its not sql syntax:

select * from table order by [count(*) from other_table where
username=table.username]

can anyone help me out?

thanks guys!



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] TO_DAYS() equivalent?

2001-07-11 Thread Noah Spitzer-Williams

check out the mktime() function

David W. Banks [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Is there some way to get the equivalent of select TO_DAYS(NOW())
 out of PHP without querying MySQL (or whatever.) Some formatting character
 for the date() function that I'm just missing?

 Thanks,
 -Dave

 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] most efficient weighting system? URGENT

2001-06-30 Thread Noah Spitzer-Williams

if i have several rows in a table and i want some to have certain weights
what is the best way to pick a random row based on its weight?

ex of table:
idweight
1 10
25
33
420
52

therefore, since there is a total weight of 40, id 1 should be picked 25%
(10/40) of the time, id 4 50% (20/40), etc...

what is the best way to do this?

- Noah



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] advantages/disads of primary keys and indices?

2001-06-23 Thread Noah Spitzer-Williams

I see,

What about if you had 3 or 4 columns that would always be unique, is there
an advantage to naming them as primary keys? does this slow inserts because
it has to check if theres a duplicate entry?


Manuel Lemos [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello Noah,

 On 22-Jun-01 21:17:35, you wrote:

 what are the advantages and disadvantages of primary keys and indices?

 A primary key is a unique index.

 Use indexes for the fields that will be most looked up in the first
 condition of the WHERE clause of your SQL queries, especially if your
 tables will hold many values, but beware that indexes also take disk
space.


 Regards,
 Manuel Lemos

 Web Programming Components using PHP Classes.
 Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
 --
 E-mail: [EMAIL PROTECTED]
 URL: http://www.mlemos.e-na.net/
 PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
 --


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] advantages/disads of primary keys and indices?

2001-06-23 Thread Noah Spitzer-Williams

Yeah the keys would be part of the first condition of the where clause...

this table is like this:
username | siteid | bannerid | clicks | someotherstat


an update would be like: update tbl set clicks=clicks+1 where
username='something' and siteid='something' and bannerid='something'

a select would be: select clicks from tbl where username='something' and
siteid='something' and bannerid='something'


so knowing this, does it make sense to make primary keys out of
username,siteid,bannerid?

Thanks!

- Noah


Manuel Lemos [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hello Noah,

 On 23-Jun-01 12:10:20, you wrote:

 I see,

 What about if you had 3 or 4 columns that would always be unique, is
there
 an advantage to naming them as primary keys? does this slow inserts
because
 it has to check if theres a duplicate entry?

 What really slows down is updating the index with the new entry value.

 Anyway, some times it may pay to slow down inserts and updates for very
 large tables.  You have to check if the indexes/primary keys that you are
 adding are used as the first condition of the WHERE clause.



 Regards,
 Manuel Lemos

 Web Programming Components using PHP Classes.
 Look at: http://phpclasses.UpperDesign.com/?[EMAIL PROTECTED]
 --
 E-mail: [EMAIL PROTECTED]
 URL: http://www.mlemos.e-na.net/
 PGP key: http://www.mlemos.e-na.net/ManuelLemos.pgp
 --


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP-DB] advantages/disads of primary keys and indices?

2001-06-22 Thread Noah Spitzer-Williams

what are the advantages and disadvantages of primary keys and indices?

- Noah



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]