This is really actually meant for future reference for myself as lately I’ve been doing quite a lot of Joomla! mysql coding and have used the following code just short of 3million times.

[code lang=”php”]
$db = JFactory::getDbo();
$querySelectId = “SELECT `id` FROM #__some_table WHERE `user_id`=’$user_id'”;
$data = $db->loadAssoc();

What we do in the above code snippet is select a user_id from some_table (#__) is short for whatever your database table’s prefix is (Joomla! replaces this itself) and then we perform the query and return the row’s `id` into the $data variable.