The manual says that inside double-quoted strings, "variables within the string will be expanded (subject to some parsing limitations)."
Looks as if this is one of those limitations. Since an underscore is legal in a variable name, PHP is replacing $abc_ (whose value is unset).
Workaround would be to use the concatenation operator:
WHERE details.id ='$abc" . '_' . "$def'"
Note that in your example you used $123, which is not a legal variable name.