Note that there are some explanatory texts on larger screens.

plurals
  1. POHelp Creating a MYSQL Query
    primarykey
    data
    text
    <p>Firstly - Could you tell me if there is a better way to do this, perhaps using foreign keys... I once read about them but don't really understand how to use them.</p> <p>I have two tables that I would like to get get data from. AccountDetails and AccountUsage both tables have a unique id of AccountID that should match for each user.<br> I need to compare the AccountEmail in the table AccountDetails to a value that the user has imputed, and then if there is a match, get all of the data from both tables and update data in AccountUsage. I understand i might need another query to update the data in AccountUsage but just mentioned it in case there is another way to do it, It will update the LastLogin to today's date.</p> <p>So, I hope your still with me, this is the code that i have at the moment,</p> <pre><code>SELECT AccountID, AccountPassword, BandID FROM AccountDetails WHERE AccountEmail=? </code></pre> <p>After all of that - the key points are;</p> <ul> <li><p>Is there a better way with foreign id's (really don't know if these are relevent in this).</p></li> <li><p>If not, canyou help me with the query, I think a join is required?</p></li> <li><p>Is there a way to automaticaly upadate the LastLogin to todays data or do i need another query?</p></li> </ul> <p>Thank You So Much<br> Chris</p> <p><strong>EDIT:</strong> This is some code i used last time (im converting the application to oop php).</p> <pre><code>SELECT AccountUsage.AccountID, AccountUsage.AccountActive FROM AccountUsage INNER JOIN AccountDetails ON AccountUsage.AccountID=AccountDetails.AccountID WHERE AccountDetails.AccountEmail=? </code></pre> <p>This was after already running a different query to get data from the first table, idealy i would like it all in 1 query.</p> <p>Return format as an array would be nice, for php.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload