Error wheng getting value from table row by two arguments in WHERE clause

by X9DESIGN   Last Updated April 28, 2018 00:10 AM

I trying to use code below to print in HTML output a specific value. I need to get this value by two arguments in WHERE clause. Unfortunately this cause an error.

    function getDlaczegoTyByID($id) {

        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $query->select($db->quoteName('profile_value'));
        $query->from($db->quoteName('chdg4_user_profiles'));
        $query->where($db->quoteName('profile_key') . ' = "profile.dlaczegoty" AND ' . $db->quoteName('user_id') . ' = '. $id);

        $db->setQuery($query);
        $results = $db->loadResult();

        return $results;

    }

    echo getDlaczegoTyByID($usr_id) . "\n";

ERROR: Unknown column 'profile.doswiadczenie' in 'where clause' SQL=SELECTprofile_valueFROMchdg4_user_profilesWHEREprofile_key= profile.doswiadczenie ANDuser_id= 298

As You see above SQL query in error looks fine. I used many times two arguments in WHERE clause when I was doing it with a standard mysql query. Why this does not work by Joomla queries?

Thanks in advance for help.

Tags : mysql select


Related Questions


Select+Checkboxes fields = query a Database

Updated February 12, 2017 14:04 PM

How to select records one by one using JDatabaseQuery

Updated February 03, 2018 13:10 PM


How can non alphabetic characters be selected?

Updated June 27, 2017 09:10 AM