MySQL two tables and an uneven number of rows
[email protected] (Karl DeSaulniers) Sun, 11 Sep 2016 22:24:21 -0500
| Newsgroups | php.db |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_94462E36-573D-46A8-8CF5-B617FCCBAE7F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Hello All, Hoping you can help clear my head on this. I have two MySQL tables for = custom fields data to be stored. custom_fields custom_fields_meta custom_fields is the info for the actual field displayed in the html and = custom_fields_meta is the data stored from entering a value on said = field in the form. Custom fields can be added and removed at will by the user and so when = for instance, adding a field,=20 it currently creates an uneven number of rows in the custom_fields_meta = if there were any entries with fields create prior to this new one. Currently I have this code: $SQL =3D "SELECT ft.*, mt.Meta_Value=20 FROM `CUSTOM_FIELDS` ft=20 LEFT JOIN `CUSTOM_FIELDS_META` mt=20 ON mt.Field_ID =3D ft.Field_ID=20 WHERE mt.Order_ID=3D%d=20 ORDER BY ft.Field_ID ASC"; I have tried JOIN, FULL JOIN, FULL OUTER JOIN, OUTER JOIN and LEFT JOIN.=20= If I manually put in the missing rows in the meta table, left join = works. However, manually updating prior entries is not going to happen.=20 So my question is how do I get all the table rows in both tables even if = there is not a row to match on the meta table? or How would I update the prior entries to include this new field in the = meta table and keep things orderly? The meta is stored per order id and so there is groups of meta data per = order id. I would like to avoid scattered data. Is there a way to push the index down to fit them in or is this just = going to be too costly on server resources? TIA, Best, Karl DeSaulniers Design Drumm http://designdrumm.com <http://designdrumm.com/> --Apple-Mail=_94462E36-573D-46A8-8CF5-B617FCCBAE7F--